Skip Navigation

[Resolved] I want to add fields to a cont.templ. (child CPT) from the parent (Parent CPT)

This thread is resolved. Here is a description of the problem and solution.

Problem: From the Content Template of a child post, I would like to display information from a custom field on its parent post.

Solution: Place a types field in your Content Template, using the custom field slug and the parent post type slug:

[types field="field-slug" id="$parent-post-type-slug"][/types]

Relevant Documentation:
https://toolset.com/documentation/user-guides/displaying-fields-of-parent-pages/

This support ticket is created 7 years, 3 months ago. There's a good chance that you are reading advice that it now obsolete.

This is the technical support forum for Toolset - a suite of plugins for developing WordPress sites without writing PHP.

Everyone can read this forum, but only Toolset clients can post in it. Toolset support works 6 days per week, 19 hours per day.

Sun Mon Tue Wed Thu Fri Sat
8:00 – 12:00 8:00 – 12:00 8:00 – 12:00 8:00 – 12:00 8:00 – 12:00 - -
13:00 – 17:00 13:00 – 17:00 13:00 – 17:00 13:00 – 17:00 13:00 – 17:00 - -

Supporter timezone: America/New_York (GMT-04:00)

This topic contains 2 replies, has 2 voices.

Last updated by nicklasK 7 years, 3 months ago.

Assisted by: Christian Cox.

Author
Posts
#563174

I have created a content template for a child CPT. I am trying to add custom fields to the content template that "belongs" to the parent (Parent CPT). So I want to create a content template that combines custom fields from both the child CPT and the parent CPT.

Link to a page where the issue can be seen: hidden link

I expected to see: a content template for a child CPT that also displayed custom fields from the parent CPT ("company logo" and "post title with a link")

Instead, I got: a content template for a child CPT that did not displayed custom fields from the parent CPT.

#563267

Hi, we have information about accessing parent field details here:
https://toolset.com/documentation/user-guides/displaying-fields-of-parent-pages/

The general idea is that you pass an ID attribute into the field shortcode, and specify the parent post's slug:

[types field="field-slug" id="$parent-post-type-slug"][/types]

You can do the same with Views shortcodes:
https://toolset.com/documentation/user-guides/views-shortcodes/

#563339

It worked! Thanks a bunch! 😀

/Nicklas