Support

Account

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!