Home › Forums › General Issues › Output Select label, based on page parent ID › Reply To: Output Select label, based on page parent ID
Thanks Elliot. Further bit of testing, from this code block:
<?php // Color scheme
// --------------------------------------------------------------------------------
// Grab the color scheme for pages. Sub pages inherit the parent's color scheme.
// http://wordpress.org/support/topic/plugin-advanced-custom-fields-field-from-parent-page-into-child-page
global $post;
// Get parent ID
$parent_id = $post->post_parent;
// Parent color
$color_scheme_parent = get_field('color', $parent_id);
?>
<?php
/*
* Displaying a single value's Label
*/
$field = get_field_object('color_scheme_color');
$value = get_field('color');
$label = $field['choices'][ $value ];
?>
Color field: <?php echo $field; ?> <br>
Color value: <?php echo $value; ?> <br>
Color label: <?php echo $label; ?> <br>
Parent color: <?php echo $color_scheme_parent; ?>
I get this output on the page (page.php):
Color field: Array
Color value: #464972
Color label:
Parent color: #464972
Do you have any other de-bugging suggestions or tests I could perform to see why I can’t output the label?
Many thanks!
Welcome to the Advanced Custom Fields community forum.
Browse through ideas, snippets of code, questions and answers between fellow ACF users
Helping others is a great way to earn karma, gain badges and help ACF development!
ACF wouldn’t be so widely used in WordPress if it didn’t have some pretty amazing capabilities. In this article, we look at a few of the features we’ll discuss during “7 things you didn’t know you could do with ACF” at #WPEDecode later this month. https://t.co/5lnsTxp81j pic.twitter.com/Yf0ThPG1QG
— Advanced Custom Fields (@wp_acf) March 16, 2023
© 2023 Advanced Custom Fields.
We use cookies to offer you a better browsing experience, analyze site traffic and personalize content. Read about how we use cookies and how you can control them in our Cookie Policy. If you continue to use this site, you consent to our use of cookies.