WordPress.org

Support

Support » Plugins and Hacks » Advanced Custom Fields » [Resolved] [Plugin: Advanced Custom Fields] Field from parent page into child page

[Resolved] [Plugin: Advanced Custom Fields] Field from parent page into child page

  • I’ve been trying to get the value from a parent page’s custom field (specifically an image url) into a child page so that it shows both on the parent and on the child page. Essentially an image that gets shown on the parent page and is pulled down and shown on the child pages too.

    The problem is that when I call the field on the child page, nothing comes up. I’ve tried to use parent page IDs, trying to tell it to get it from $post->post_parent as per this suggestion but to no avail.

    How can I pull the value to a child page from a parent page using Advanced Custom Fields? Any Suggestions?

    http://wordpress.org/extend/plugins/advanced-custom-fields/

Viewing 1 replies (of 1 total)
  • Plugin Author elliotcondon

    @elliotcondon

    Hi there,

    ACF’s API functions the_field and get_field allow for a second parameter to specify the post_id to target. Therefore you could write soemthing like this:

    <?php
    
    global $post;
    $parent_id = $post->post_parent;
    
    $field_from_parent = get_field('field_name', $parent_id);
    
    ?>

    Good luck

Viewing 1 replies (of 1 total)
  • The topic ‘[Resolved] [Plugin: Advanced Custom Fields] Field from parent page into child page’ is closed to new replies.
Skip to toolbar