Showing Only Posts with Related Items
Learn how to display the posts with related items only using the JetEngine WordPress plugin.
This guide explains how to display a list of the posts that only have the related items. You will learn how to set up a new macro to retrieve items with related items using the JetEngine WordPress plugin.
Add the Code
First, add the following code to the functions.php file of the child theme, or into the Code Snippets plugin, or any other plugin for code snippets.
In this case, we use the Code Snippets plugin. Click the “Save and Activate” button.
Adjust a Query
Proceed to WordPress Dashboard > JetEngine > Query Builder and click the “Add New” button.
Enter the Name for a query and select the “Posts Query” Query Type. In the General tab, select the required Post Type.
Proceed to the Post & Page tab, and select the “Items with Relation” option for the Post In field. In the newly opened pop-up, select the required relation in the From Relation dropdown, and whether you need to display parents or children items from the relation in the From Object (what to show) field. Click the “Apply” button.
Click the “Add / Update Query” button to save the query.
Set Up a Listing Template
Following the How to Create a Listing Template for Post Types in Elementor guide, set up the Listing Template for the Custom Post Type you want to show posts from.
Click the “Publish” button once you are ready.
Add the Listing to the Page
Go to the page where you need to display posts with related items. Add the Listing Grid widget and select the listing template you created. In the Custom Query tab, enable the Use Custom Query toggle and select the query created earlier.
Click the “Publish” button.
Check the Result
In this case, we have three posts with the connected relations.
On the front end, we only get these posts with the related items.
That’s it. Now you know how to display the posts with related items only using the JetEngine WordPress plugin.






