Skip Navigation

[Resolved] Displaying Grandparent Post-Link on Grandchild Post

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

Problem:
How to display a field from a grandparent post on a grandchild post?

Solution:
The documentation describes displaying grandparent fields in a View, but you may want to display then directly in the template for grandchild posts.

The basic steps are
- create a Content Template (not assigned to any post type) to hold the fields of the grandparent you want to display.
- imagine that the starting point for *this* template is the parent post. Use the Fields and Views button to insert the required fields, and the Post selection tab to specify that the source is the parent post from the "grandparent-parent" relationship (which, if this is the parent, will be the grandparent).
- now edit the template for the grandchild posts. Insert the Content Template you just made (again, with the Fields and Views button), and use the Post selection tab to specify that the source is the parent of the current post from the "parent-grandchild" relationship.

So, starting from our grandchild post, we insert a Content Template where we specify that the source is the parent post, so that the template "thinks" its context is the parent. So when the fields inside are told to display fields from the parent, it is the parent of the parent.

Relevant Documentation:
https://toolset.com/documentation/post-relationships/how-to-display-related-posts-with-toolset/displaying-fields-of-grandparents/

This support ticket is created 6 years, 4 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.

No supporters are available to work today on Toolset forum. Feel free to create tickets and we will handle it as soon as we are online. Thank you for your understanding.

Sun Mon Tue Wed Thu Fri Sat
- 7:00 – 14:00 7:00 – 14:00 7:00 – 14:00 7:00 – 14:00 7:00 – 14:00 -
- 15:00 – 16:00 15:00 – 16:00 15:00 – 16:00 15:00 – 16:00 15:00 – 16:00 -

Supporter timezone: Europe/London (GMT+00:00)

This topic contains 2 replies, has 2 voices.

Last updated by KentS9937 6 years, 4 months ago.

Assisted by: Nigel.

Author
Posts
#956806

I'm doing something very similar to the article at https://toolset.com/documentation/post-relationships/how-to-display-related-posts-with-toolset/displaying-fields-of-grandparents/. I'm trying to display the Post-Link field of the grandparent on the grandchild post.

Based on this support article https://toolset.com/forums/topic/displaying-grandparent/#post-590115, I think I need to include "id=$field-slug" when inserting the content template.

Following these instructions I tried inserting content template with the following.

[wpv-post-body id="$post-link" item="@property-in-a-city.parent" view_template="country-information"]

This isn't working. Can you advise if I'm on the right track to include the id="$field-slug"?

Thanks

#957148

Nigel
Supporter

Languages: English (English ) Spanish (Español )

Timezone: Europe/London (GMT+00:00)

Hi Kent

That forum post pre-dates the updates to how post relationships work in Types 3 and you had better stick to the documentation to avoid mixing the two approaches. In particular, you no longer use the id attribute to refer to the parent post slug, you use the item attribute.

You have lifted this straight out of the documentation

[wpv-post-body id="$post-link" item="@property-in-a-city.parent" view_template="country-information"]

which is based upon the post types and relationships of the example, and presumably yours are different (unless you are exactly trying to reproduce what is in the docs).

Use the Fields and Views button to insert the shortcodes, and the Post Selection tab in the GUI to specify the source when it is anything other than the current post.

The documentation describes displaying grandparent fields in a View, but you may want to display then directly in the template for grandchild posts.

The basic steps are
- create a Content Template (not assigned to any post type) to hold the fields of the grandparent you want to display.
- imagine that the starting point for *this* template is the parent post. Use the Fields and Views button to insert the required fields, and the Post selection tab to specify that the source is the parent post from the "grandparent-parent" relationship (which, if this is the parent, will be the grandparent).
- now edit the template for the grandchild posts. Insert the Content Template you just made (again, with the Fields and Views button), and use the Post selection tab to specify that the source is the parent of the current post from the "parent-grandchild" relationship.

So, starting from our grandchild post, we insert a Content Template where we specify that the source is the parent post, so that the template "thinks" its context is the parent. So when the fields inside are told to display fields from the parent, it is the parent of the parent.

#957277

Thanks for your quick reply. What you described is what I first attempted. It wasn't working so I started looking for tips in the support forum. I now understand I was referencing an outdated solution. I'll go back and double check my relationships and content template. Thanks for your help.