Skip Navigation

[Closed] Displaying grandparent data on slider with Blocks

This support ticket is created 4 years, 1 month 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)

Author
Posts
#1863407
Slider - with Blocks.jpg
Slider - the old way.jpg

Tell us what you are trying to do?

Hi, I had built sliders the old way (not using blocks). Now I am trying to do the same but now with the Blocks. I followed the tutorial on how to build sliders with blocks but now I have to display a chunk of data that belongs to a grand grandparent of an actual custom post.
My site is structured in levels:
Level 01 - Areas
Level 02 - Guides
Level 03 - Regions
Level 04 - Destinations
Level 05 - Attractions
All levels are in one-to-many relationships (1 Area - many Guides ... etc.) Slider displays Attractions (image, heading, parent heading (Destination) and button) but I need one extra data - Guides. So I want to display the related Level 02 heading (post title) on Level 05.
See attachments.

What is the link to your site?
hidden link

#1863865

Hi, there's not really an easy way to create this type of setup completely in the Blocks editor because the Dynamic Sources feature only allows you to get information one level up in the hierarchy, and does not allow you to set the post context of a Content Template block. So inside a View of Attractions, you could access information from the parent Destination using Dynamic Source, but not information from related Regions, Guides, or Areas up the chain of hierarchy. You would need to create a nested Content Template structure that switches the context at each level, up the hierarchy, using the "item" shortcode attribute and the "@relationship-slug.parent" syntax.

For example, you would create one Content Template (in this example, the template has the slug "first-level-content-template") and place it in the View of Attractions using a shortcode to switch the context to the parent Destination post like so:

[wpv-post-body item="@destination-attraction.parent" view_template="first-level-content-template"]

You would replace destination-attraction in this shortcode with the slug of the relationship between Destination and Attraction.

Then you would create another Content Template (in this example, the template has the slug 'second-level-content-template") and place it inside the first-level-content-template, to switch the context again to the Region post like so:

[wpv-post-body item="@region-destination.parent" view_template="second-level-content-template"]

You would replace region-destination in this shortcode with the slug of the relationship between Region and Destination.

Then you would create a third Content Template (in this example, the template has the slug 'third-level-content-template") and place it inside the second-level-content-template, to switch the context again to the Guide post like so:

[wpv-post-body item="@guide-region.parent" view_template="third-level-content-template"]

You would replace guide-region in this shortcode with the slug of the relationship between Region and Destination.

Then inside the third-level-content-template, you can place whatever shortcode you need to display information about the Guide post, like the post title:

[wpv-post-title]

...or a custom field:

[types field="some-field-in-guide-post"][/types]

Now you have a nested Content Template structure inside the View of Attractions that switches the post context all the way up the chain of hierarchy to the Guide post, and displays information about that Guide post.

It's a bit convoluted so if you get stuck let me know. I can take a closer look at your setup and provide feedback.

The topic ‘[Closed] Displaying grandparent data on slider with Blocks’ is closed to new replies.