Help Center

How to Create a Featured Listing

Learn how to display featured posts at the top of the list and how to show featured posts only after successful payment, using the JetEngine, JetFormBuilder, and JetPopup plugins for WordPress websites.

Before you start, check the tutorial requirements:

In this tutorial, we will focus on two cases: displaying featured posts at the top of the list and showing featured posts only after a successful payment.

This method involves ordering the Listing Grid according to the “Featured” meta field, so the featured posts are shown at the top of the list.

In this tutorial, we use the “Switcher” meta field to define if the post is featured. 

To add the field, proceed to WordPress Dashboard > JetEngine > Post Types, click the “Add New” button, or edit the already existing post type. You can check the details on setting up a new Custom Post Type (CPT) from our How to Create a Custom Post Type tutorial. In our case, we will add the “Switcher” meta field to the “Services” CPT.

click the edit button for cpt

On the newly appeared page, scroll down to the Meta Fields tab and click the “New Meta Field” button.

Fill out the Label and select the “Switcher” option in the Field Type dropdown.

switcher meta field added to cpt

Once you have adjusted the settings, click the “Add/Update Post Type” button. 

Now, we need to set the values for the posts. From the WordPress Dashboard, proceed to the needed post type and either click the “Add Page” button or edit the existing post.

click the edit post button

Enable the “Switcher” field toggle or leave it disabled, and click the “Save” button once you are ready.

switcher field toggle activated

Create a listing template

Following the How to Create a Listing Template for Post Types in Elementor tutorial, we created the Listing Template for the Post Type

In this case, we added Dynamic Field widgets to display the title of the post and a meta field with a short description.

listing template created

In our case, we would like to add a label for the featured posts to be shown on the featured posts only. For this, we used the Elementor Button widget and styled it according to our needs. 

Now, proceed to the Dynamic Visibility section in the Advanced tab and activate the Enable toggle.

dynamic visibility is enabled

Then, select the “Switcher enabled” Condition

Click the “Dynamic Tag” icon on the right side of the Field selector. Scroll down to the JetEngine section and choose the “Custom Field” option.

dynamic tag dropdown menu with custom field option visible

In a newly appeared pop-up, pick the meta field from the dropdown (the “Featured” field in our case).

custom field selected in the “switcher enabled” condition settings

Once you are ready with the settings, click the “Publish” button.

Adjust a custom query

Now, we need to create a Posts Custom Query to order the posts by the “Switcher” meta field, so the featured posts are shown at the top of the list. 

Proceed to the WordPress Dashboard > JetEngine > Query Builder and click the “Add New” button. 

Add the Name for the query and keep the “Posts Query” option in the Query Type field. In the General tab, select the needed CPT in the Post Type field (in our case, it is “Services”).

post type selected in query settings

Scroll a bit down to the Order & Order By section. 

In the Order By field, choose the “Order by string meta value” option. In the newly appeared Meta Key field, type the name of the “Switcher” meta field (“featured” in this tutorial). Select the “From highest to lowest values (3,2,1; c, b, a)” option from the Order dropdown.

order by switcher value set up

Click the “Add Query” button.

Add the listing to the page

Now, let’s proceed to the page where the posts should be displayed. Open it in the page editor. 

Add the Listing Grid widget and in the Listing field, select the Listing Template we created earlier. After setting all the basic fields in the General tab, open the Custom Query tab and enable the Use Custom Query toggle.

Select the Custom Query you have just created in the newly appeared dropdown.

custom query applied to listing grid

Click the “Publish” button once you are ready with the settings.

Check the result

When we proceed to the frontend of the page, we see that the posts with the enabled switcher have a special label and are shown at the top of the list.

featured posts are shown at the top of the list

This part of the tutorial focuses on displaying featured posts after a successful payment. We will achieve this with the help of Dynamic Visibility, which will show the featured posts only to users with a specific role. 

Therefore, we need to set up a form that allows users to change their role after payment, so they can view the featured posts.

Set up the form

Following our How to Change User Role After Successful Subscription Payment tutorial, we created a form to update the user’s role to subscriber. 

For this, we used a Hidden Field to retrieve the current user’s ID, a Checkbox Field for users to confirm or deny that they have read the terms and conditions, and the Action Button.

form set up

Click the “Save” button to update the form settings.

Create a pop-up

You can place the form directly on the page or set it up as a pop-up. In this tutorial, we used the JetPopup plugin to create a pop-up. 

For that, proceed to the WordPress Dashboard > JetPopup > Create New Popup tab, enter the title, and hit the “Publish” and then “Edit with Elementor” buttons.

Drag and drop the JetForm widget to the pop-up and select the recently created form.

jetform widget added to the popup

When you finish, press the “Publish” button.

Warning

Ensure that the pop-up has the Conditions set up. Without it, the pop-up may not be opened on the frontend.

conditions set up for the popup

Create a listing template

We will use the listing template created in the Create a listing template step of this tutorial.

listing template created

You can refer to our How to Create a Listing Template for Post Types in Elementor tutorial to ensure the setup of a new Listing Template.

Adjust custom query

In this case, we need two Posts Queries: one to show featured posts only and another to show ordinary posts. 

So, proceed to the WordPress Dashboard > JetEngine > Query Builder and click the “Add New” button. 

Add the Name for the query and keep the “Posts Query” option in the Query Type field. In the General tab, select the needed CPT in the Post Type field (in our case, it is “Services”).

general tab set up in the custom query

Then, open the Meta Query tab and click the “+Add new clause” button. 

Put the switcher’s field name in the Field key/name input. You can also use “JetEngine meta field” macros to get the name of the field created by JetEngine. Select the “Equal (=)” operator from the Compare dropdown. In the Value input, set “true” to get the posts with the enabled switcher, and “false” for the posts with the deactivated switcher (in this case, we use the “true” value). Choose the “Char” data type for the Type field.

meta query set up with the “true” value

Click the “Add Query” button once you’re ready.

Now, we need the identical query. You can create a new query or copy the one we have just created.

copy query button clicked

The only thing we need to change is the Value field in the Meta Query tab. In our second query, we used the “false” value.

meta query set up with the “false” value

Click the “Add Query” button once you’re ready.

Set up the page

Open the page where you need to display the listings. 

First, we added the featured posts list. For that, add the Listing Grid widget, and after setting all the basic fields in the General tab, open the Custom Query tab and enable the Use Custom Query toggle.

Select the Custom Query to display posts with the enabled switcher (set to “true”).

query to show featured posts is selected

Then, navigate to the Advanced section. Go to the Dynamic Visibility tab, open it, and enable the toggle.

Select the “Show element if condition met” Visibility condition type, “User Role is not” Condition, and choose the User role (in this tutorial, we selected “Subscriber”).

dynamic visibility for the featured posts

Now, we add one more Listing Grid widget and attach a different custom query to it to display only the non-featured posts.

query to show non-featured posts is selected

Finally, we added the Button widget to open the pop-up. In the General tab, we changed the Text to “Open Featured Services”. 

Navigate to the Advanced section, move to the JetPopup tab, and attach the recently created pop-up. Select the Trigger Type you need. To attach the pop-up to the Button widget, we select the “Click on Button” option.

popup attached to the button widget

Click the “Publish” button once you’re ready.

Check the result

To see how the setup works, we need to be sure that we are visiting the site as a guest.

Warning

Be aware that logging into the second account with the customer role is necessary to test the form. If you submit the form from the main account, your administrator role can be changed to a subscriber.

Let’s proceed to the frontend page. 

We see only non-featured posts and the button to see featured services.

only non-featured posts are visible to the guest

When we click the button, the pop-up with the form opens.

form in the opened popup

Log in to the PayPal account and buy a subscription. After that, you will return to the page where Dynamic Visibility will show the featured services. That means the user role was changed successfully.

the featured posts are visible for the subscriber

That’s it. Now you know how to display featured posts first, and only after a successful payment, using the JetEngine Dynamic Visibility, JetFormBuilder, and JetPopup plugins for WordPress websites.

Was this article helpful?
YesNo

Need help?

Ask Facebook community

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

Start a live chat

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