Back to contents

JetElements: How to Create and Apply a Custom Query to Posts Widget

This tutorial will be helpful, if you need to display your posts in a certain order. Ir shows how to create and apply a custom query to Posts widget of jetElements plugin with the help of WP Query Generator tool.

WP Query Generator tool allows you to create any type of custom query really easily. In this tutorial, we will show you how it works on the example of the query that sorts the posts according to the publication date.

An order based on the publication date is the most common for posts. By default, it is the descending order, when the most recent post is shown first. You might need to change it to ascending order when the latest posts are shown last.

Let’s take a look at how the order of the posts could be changed by inserting a custom query.

1 Step — Generate the query

Open the page where you have placed the posts grid with Elementor page builder, find the Posts widget, and click the “Edit Posts” button. If you haven’t yet created the posts grid or slider – check out posts grid or posts carousel creation tutorial.

After that, let’s navigate to the WP Query Generator tool. Open General tab and specify the following conditions for your new query:

  • Post type: post;
  • Post status: Publish
  • Order: ACS (stands for ascending order);
  • Order by: date.
WP Query Generator

Copy the generated query to clipboard and return to Elementor editor. Open Content > General and enable Use Custom Query option. Paste the generated code to the Set custom query text field.

Set custom query

Well, that’s all. Now you know how to generate and apply the custom queries to the posts.