Let’s dive deeper into the alternative Meta query and Tax query relations and how to choose the one that meets your needs the most. We’ll use the Listing Grid widget possibilities of the JetEngine plugin.
Let’s get started!
Step 1 – Ensure, that you have previously created the Custom post type with some posts in it. To discover the details, please, go to this tutorial.
Step 2 – Then, consider, that you’ve added Taxonomies to the posts. Read more here.
For example, for posts of ‘Taxi order’ post type, we have the taxonomy ‘price more than 10$ per mile’ to be showcased.
Step 3 – The next step is to check, that you’ve created the Meta Boxes and added information to each post. Follow the link to learn more.
In our case, we have Meta Field ‘Parking’ in each post, which we fill with two values: ‘Parking’ and ‘No Parking’.
Step 4 – After that, make sure, that you have created a single listing template. Read this tutorial to learn more about this topic.
How to add several posts query relations for one publications listing
Step 1 – Now, you are in Elementor editor and have the needed listing added to the page.
Step 2 – After that, in the Posts Query tab, you should add the new item with the corresponding button and choose the Posts Parameters type.
Step 3 – In the field Exclude posts by ID you need to enter the macros ‘%current_id%’ to hide the currently displayed posts on the page from the query.
Step 4 – Next, proceed to the Content > Posts Query tab. Select in the dropdown menu the Tax Query type and choose the appropriate type of data in the Taxonomy dropdown.
Alternatively, you can put the taxonomy from the meta field by entering the taxonomy name in the corresponding field.
Step 5 – Select the correct Operator in the dropdown menu. We have the ‘IN’ one, but you can choose the one meets your requirements.
Step 6 – In the Field dropdown you should select the ‘Term ID’ option and in the Terms field put in the macros ‘%current_terms%’ to display the posts with the same term (the one you have previously set in the taxonomy field).
Step 7 – Then, you should in the Posts Query tab add new item and select the Meta Query type. In the Key field, you should enter the Name / ID of the Meta Field to be shown. Select the appropriate operator in the dropdown menu (in our case, the ‘Equal’ operator suits us).
Step 8 – Fill in the field that is called Value with the one that you want posts to be displayed. For example, we add ‘Parking’ value and all posts with the corresponding value appears.
Meta query and Tax query relations
Step 1 – In the Posts Query tab under the items, you will see the options Meta query and Tax query relations.
Step 2 – Here, in each relation type you can choose either ‘AND’ or ‘OR’ operator.
AND operator displays a record if all the conditions separated by AND are TRUE.
OR operator displays a record if any of the conditions separated by OR is TRUE.
Now you are able to add several Meta query and Tax query relations and display them in your page.