Support

Account

Home Forums General Issues How to inherit field value from parent post into in child / sub post

Solved

How to inherit field value from parent post into in child / sub post

  • I have created a custom post type, called ‘centres’. This CPT is hierarchical, ie, I can create child pages under each custom post.

    Centre1
    – Location1
    – Contact1
    Centre 2
    – Location2
    – Contact2

    I’ve defined a custom field called phone_number. This field is populated at the ‘parent’ level. Ie, Centre1, Centre2.

    I want to display the phone number on each child page. I don’t want to have to add the phone number every time to each page, so would like to get or inherit the phone_number field from its parent.

    Simply speaking, I’d like to just add the shortcode [acf field="phone_number"] in any given child page (eg, contact page) and have it pull the values from it’s parent.

    I’ve searched everywhere, but can’t find a solution. I’m a novice wordpress user (not a php developer). Is there code I can add into my functions.php file that can get the ACF values of a particular field (or all fields) from the parent?

    Much appreciated.

Viewing 2 posts - 1 through 2 (of 2 total)

You must be logged in to reply to this topic.