Back to contents

How to inject listing template depending on item meta field value

useful information

This tutorial will be useful by injecting alternative listing items depending on their meta field value with the help of JetEngine functionality.

You are able to set and display some alternative listing templates with different style settings in one Listing Grid widget. We are going to present an example based on showing an alternative listing item depending on its meta field value using JetEngine.

1 Step — Create the listings

We create two listings, Listing Country and Listing Country 1, with the same content in each of them.

listing country

The Listing Country 1 listing has a different style: the position of the items, the title color and there is a discount label on the image.

listing country 1

2 Step — Set the Listing Grid widget

Now we open the page, where we use the Listing Grid widget and proceed to adjust appropriate widget’s settings to display an alternative Listing Country 1 listing in the main listing.

  • In the Listing field, choose the Listing Country listing and enable the Inject alternative listing items below.
  • choose the listing
  • Click the +Add Item button and set the needed options. In the Listing template line select the Listing Country 1 listing and in the Inject on field Depends on item meta field value option. Then, in the Key (name/ID) field paste the meta field name, set the certain operator and specify the corresponding value.
    So, the alternative listing style will be applied to a certain post, which has the meta field with the defined value.
an alternative listing in the Listing Grid widget
NOTE!
You can change the meta field, the operator, etc. according to your needs.

3 Step — View the listing grid on the frontend

Save the changes and view the result on the frontend.

listing with an alternative listing

Great! Now you know how to set the Listing Grid widget for displaying alternative listings depending on their meta field values.