Help Center

How to Build Grandparent/Grandchild Relations (Legacy)

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.

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

Warning

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:

%get_grandparent|post-type-slug%

%get_grandchild|post-type-slug%

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

%get_grandparent|post-type-slug%

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:

%get_grandchild|post-type-slug%

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.

Was this article helpful?
YesNo

Need help?

Ask Facebook community

Get answers from 22K Crocoblock Community experts from all over the world.

Start a live chat

Ask question to support agent and share its details via chat messages.