Stand with Ukraine. Fight for freedom and democracy

Back to contents

JetEngine: How to Build Grandparent/Grandchild Relations

This tutorial describes how to display the grandparent/grandchildren post type relations using the WordPress JetEngine Listing Grid widget or block. The tutorial contains the instructions for the legacy and refactoring (JetEngine 2.11 update) relations.

You can watch such a video tutorial to know how to set the Legacy grandparent/grandchild relations.

Tutorial requirements:

  • 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.

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.

Well, let’s do not waste time and walk through the process:

How to Create the Grandparent/Grandchildren Relation

Go to WP Dashboard > JetEngine > Relations.

relations list

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.

convert relation into the new format

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.”

parent relation

How to Display the Legacy Grandparents/Grandchildren Relation Posts with Macros

knowledge base information icon
NOTE! The following macros work only with the legacy relations. Legacy relations are those that were created before the JetEngine 2.11.0 update.

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:

grandparent macro in the listing grid widget in the elementor editor

In the Gutenberg editor:

grandparent macro in the listing grid block 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.