How to Build Grandparent/Grandchild Relations (Legacy)
This tutorial describes how to display the grandparent/grandchildren post type relations using the WordPress JetEngine Listing Grid widget or block.
To know how to set the Legacy grandparent/grandchild relations, watch this video tutorial.
The grandparent/grandchild relations type allows setting the connection between two already existing relations.
To create this type of hierarchical path, you need to use the JetEngine Listing Grid widget or block that helps you display the particular Listing and set the relation with the help of macros.
How to Create the Grandparent/Grandchildren Relation
Go to WP Dashboard > JetEngine > Relations.
If you have any Legacy relations, you can update them. Hit the “Edit” button near the needed relation, and then hit the “Convert into the new format” button. After that, all posts will be automatically transferred, but you must manually change macros used for relations.
Now, you need to create a grandparent/grandchild relation between Continent and Tour. To make it work, go to the Country > Tour relation and set the Parent relation as “Continent > Country.”
How to Display the Legacy Grandparents/Grandchildren Relation Posts with Macros
If you decide not to update the relations and leave them legacy, you can use the following macros to display the grandchildren or grandparent posts in the Listing Grid widget or block:
For example, to display the grandparents posts, navigate to the grandchildren Single Post (Tour, in our case) in the Elementor or Block editor.
Place the Listing Grid widget or block here.
Go to the Post Query tab, click on the “Add Item” button, select the “Posts & Authors Parameters” Type, and enter the macros
where you should change the part “post-type-slug” to the CPT slug (e.g., “tour”) to showcase the data (continent) related to a certain Tour.
Also, it is possible to make it vice versa, display the Tour Listing with the Listing Grid in the Single Continent, and then we need to use such a macro:
In the part “post-type-slug” you need to enter the slug of the grandparent post. In our case, it would be “continent”
Here is what we’ve got. In the Elementor page builder:
In the Gutenberg editor:
How to Display the Refactoring Grandparents/Grandchildren Relation Posts with Macros in Query
How to do that you can learn from this tutorial.
That’s all. Now you know how to create and display the legacy and refactoring Grandparent/Grandchild relations.