Do you know how WordPress plugins usually implement a database query to get something (CPT, terms, custom tables data, etc.)?
All the requests are configured inside widgets, shortcodes, or blocks that output data.
According to a common approach, all queries are configured inside blocks that display their data.
From one side , it is convenient because you can quickly display the block, set up the Query, and you’re done.
But on the other hand , this approach is not comfortable if you need access data from the Query anyway on the page.
That’s why Crocoblock decided to change the approach to this issue and made the Query builder a stand-alone feature. That doesn’t depend on the widget, block, or shortcode. And in this article, I will talk about a new Query Builder feature in JetEngine.
What are JetEngine and Crocoblock?
Crocoblockdevelops plugins and templates that work with dynamic data and build even complex sites without coding. The team created 20 multifunctional plugins for Elementor and Gutenberg with hundreds of widgets and dozens of templates for three years.
JetEngine is a dynamic content plugin that is a key development of the Crocoblock team. It helps you to create:
- Custom post types (CPT)
- Custom content types (CCT)
- Custom meta fields
- Meta boxes
- Options pages
Then, you can structure it and interrelate it with the help of Taxonomies and Relations features. And for outputting all this content on the front-end, JetEngine comes with 14 widgets for Elementor and 10 Gutenberg dynamic blocks.
JetEngine is constantly updated and recently added a new Query Builder section. It provides cutting-edge features.
JetEngine Query Builder
I have already shown and explained how the query settings are usually implemented in WordPressplugins.
JetEngine Query Builder performs an entirely new approach.
The listing grid or any block that renders items is just a visual wrapper that receives data and outputs it. But the Query that gets this list from the database can exist without the block itself and still be helpful.
Thus, the items were moved to another section where they were processed. And later, the listing grid widget receives these items and displays them.
This is an example of how this approach looks like:
As you see, there is just a single query, but it shows off:
- the counter of queried items before the section renders it
- the counter of queried items inside the section before listing grid
- listing grid itself
- the counter after listing grid
Also, it can hide or show sections according to the set conditions based on the query results. All these will be performed only from query instances.
The approach to queries has become more centralized — any queries to the database are now configured in the same interface. Here the Query exists as a separate object that can be accessed at any time.
The Query is processed once and then cached. And after the first call to this Query, all further will use the cached values. Here are the advantages that you get from this approach:
- Good performance and speed
- No need to set queries for every widget anew
- Make requests at any stage of the page load
- The flexibility of adding new query types
Let’s move from the complex technical part to describing the new Query Builder’s real benefits.
Why do you need JetEngine Query Builder?
JetEngine allows querying CPT and CCT items, Terms, Users, Comments, SQL tables, and REST API.
It provides a settings section for that, but the conditions you set are applicable for the only specific listing grid. If you have similar grids on other pages and need to make some changes, you will have to change settings manually on every page when these listing grids are.
And here comes Query Builder!
It provides a single interface to create lists and add them anywhere you need. Any change on the list you make in the Query Builder menu tab will apply to all the listing grids where that Query is enabled.
Let’s take a look at specific use cases.
Use-case #1: Upsells products
Thanks to Query Builder, you can dynamically showcase the catalogue of related products on the single products page, thus stimulating your customers to buy more. Moreover, you can set visibility conditions, so this related products section will not display if there are no related items.
Use-case #2: Reviews section
Now you can dynamically display comments and user reviews about your products on the home page.
At the same time, customize the sorting of categories of comments, the date of their writing, and much more.
Use-case #3: User’s content
Display those comments left by users on their User Profile page or any Single page and query them by post status or date.
Summing up
JetEngine is a dynamic content plugin that helps you create even the most complex websites without coding skills. In the last update, JetEngine got the new module, Query Builder. It implemented building queries in a completely new way.
Paul Charlton clearly showed this in this video on the WPTuts Youtube channel :
Shortly, Query Builder is a unified system for sorting and displaying different WordPress elements — Posts, Terms, Users, Comments, SQL Tables, REST API.
Top comments (0)