You can watch such a video tutorial to know how to set the Legacy grandparent/grandchild relations.
- JetEngine plugin installed and activated;
- Three created CPTs (e.g., Continent, Country, Tour);
- Two created relations between CPTs (e.g., Continent > Country and Country > Tour);
- Apply the countries to each continent and the tours to each country. How to do that you can learn from this tutorial;
- Single Posts and Listings created for each post type; in our case, it is for the Continent, Country, and Tour.
The grandparent/grandchild relations type allows setting the connection between two already existing relations.
Well, let’s do not waste time and walk through the process:
- How to Create the Grandparent/Grandchildren Relation
- How to Display the Legacy Grandparents/Grandchildren Relation Posts with Macros
- How to Display the Refactoring Grandparents/Grandchildren Relation Posts with Macros in Query
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.