Problem: I have 4 post types related in a series of one-to-many (O2M) relationships - child, parent, grandparent, and great-grandparent posts. On the single child post template, I would like to display a breadcrumb trail from all 4 levels of post relationship hierarchy.
Solution: From any one level of the hierarchy, you can display information about that level and one level of hierarchy higher. So from the child post context, you can display information about the child and the parent. The idea is that you'll have to create 2 nested Content Templates to switch context up the hierarchy chain one level at a time. Delete the microcycle link and the two grandparent templates from the View for now. Create a mesocycle-breadcrumb template and a microcycle-breadcrumb template. First, the mesocycle-breadcrumb template will include the macrocycle template in the context of macrocycle from mesocycle, and the post link shortcode to display the mesocycle link. The mesocycle link shortcode needs no context because we will set the template context in the microcycle-breadcrumb template where we place the mesocycle template:
( in the mesocycle-breadcrumb template) [wpv-post-link item="@macrocycle-mesocycle.parent"] > [wpv-post-link]
Then, the microcycle-breadcrumb template will include the mesocycle template in the context of mesocycle from microcycle, and the post link shortcode - again, it needs no context because we will set the template context in the View where we place the microcycle-breadcrumb template:
( in the microcycle-breadcrumb template) [wpv-post-body view_template="mesocycle-breadcrumb" item="@mesocycle-microcycle.parent"] > [wpv-post-link]
Then you'll include the microcycle-breadcrumb template in the View, setting the microcycle context from the session context:
(in the Session View) [wpv-post-body view_template="microcycle-breadcrumb" item="@microcycle-session.parent"] > [wpv-post-link]
Relevant Documentation:
https://toolset.com/documentation/customizing-sites-using-php/functions/
https://toolset.com/documentation/post-relationships/how-to-display-related-posts-with-toolset/
https://toolset.com/documentation/post-relationships/how-to-display-related-posts-with-toolset/displaying-fields-of-grandparents/
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 4 years, 7 months ago.
Assisted by: Christian Cox.