{"id":41513,"date":"2023-08-09T16:49:51","date_gmt":"2023-08-09T16:49:51","guid":{"rendered":"https:\/\/crocoblock.com\/knowledge-base\/?post_type=article&#038;p=41513"},"modified":"2024-06-21T09:15:29","modified_gmt":"2024-06-21T09:15:29","slug":"combining-results-of-multiple-custom-queries","status":"publish","type":"article","link":"https:\/\/crocoblock.com\/knowledge-base\/jetengine\/combining-results-of-multiple-custom-queries\/","title":{"rendered":"How to Combine Results of Multiple Custom Queries into One Custom Query"},"content":{"rendered":"\n<p>Let us clarify which results you can get via this approach.<\/p>\n\n\n\n<p>There is a case when you need to show, e.g., Bestseller Woocommerce products first, and then other products by certain product categories in just one <strong>Listing Grid<\/strong> widget.<\/p>\n\n\n\n<p>Another use case is when the posts from different <em>JetEngine<\/em> <a href=\"https:\/\/crocoblock.com\/knowledge-base\/features\/data-store-overview\/\"><strong>Data Stores<\/strong><\/a> need to be displayed in one <strong>Listing Grid<\/strong>.<\/p>\n\n\n\n<p>There is also a case when the posts or users need to be queried by the <strong>Switcher<\/strong> meta field. Firstly you may need to show the items that have the <strong>Switcher <\/strong>in the enabled state and, after them, the items that have the <strong>Switcher <\/strong>in the deactivated state. We will see how this case can be implemented in the instructions below.<\/p>\n\n\n\n<p>To sum up, the general idea is to provide different orders\/queries for different parts of the <strong>Listing Grid<\/strong> since such a request exceeds the opportunities of just one custom query.<\/p>\n\n\n\n<h2 class=\"wp-block-heading\" id=\"add-a-meta-field-into-the-meta-box-used-in-the-query\">Add a Meta Field into the Meta Box Used in the Query<\/h2>\n\n\n\n<div class=\"wp-block-group is-layout-constrained wp-block-group-is-layout-constrained\"><div class=\"wp-block-group__inner-container\">\n<p>Before you start, ensure to create a Meta Box for users in the <strong><em>JetEngine > Meta Boxes <\/em><\/strong>tab. More details can be found in the <a href=\"https:\/\/crocoblock.com\/knowledge-base\/jetengine\/jetengine-how-to-apply-meta-boxes-to-users\/\"><strong>How to Apply Meta Boxes to Users<\/strong><\/a> tutorial.<\/p>\n\n\n\n<p>Let us add the <strong>Switcher<\/strong> meta field to the Meta Box to query the users by this field later. Save the changes by clicking the <strong>\u201cUpdate Meta Box\u201d <\/strong>button afterward.\u00a0<\/p>\n\n\n\n<div class=\"wp-block-image size-full is-resized\"><img loading=\"lazy\" decoding=\"async\" src=\"https:\/\/crocoblock.com\/knowledge-base\/wp-content\/uploads\/2023\/08\/Screenshot_120.png\" alt=\"switcher meta field in the user meta box\" class=\"wp-image-41514\" style=\"width:840px;height:464px\" width=\"840\" height=\"464\" srcset=\"https:\/\/crocoblock.com\/knowledge-base\/wp-content\/uploads\/2023\/08\/Screenshot_120.png 895w, https:\/\/crocoblock.com\/knowledge-base\/wp-content\/uploads\/2023\/08\/Screenshot_120-300x166.png 300w, https:\/\/crocoblock.com\/knowledge-base\/wp-content\/uploads\/2023\/08\/Screenshot_120-768x424.png 768w, https:\/\/crocoblock.com\/knowledge-base\/wp-content\/uploads\/2023\/08\/Screenshot_120-600x331.png 600w\" sizes=\"(max-width: 840px) 100vw, 840px\" \/><\/div>\n\n\n\n<p>Also, make sure to go to the <strong><em>Users <\/em><\/strong>tab in the admin panel, enable the <strong>Switcher<\/strong> for needed users on the user editing page, and <strong>save<\/strong> it.<\/p>\n\n\n\n<div class=\"wp-block-image size-full\"><img loading=\"lazy\" decoding=\"async\" width=\"775\" height=\"321\" src=\"https:\/\/crocoblock.com\/knowledge-base\/wp-content\/uploads\/2023\/08\/Screenshot_121.png\" alt=\"enable switcher on the user editing page\" class=\"wp-image-41515\" srcset=\"https:\/\/crocoblock.com\/knowledge-base\/wp-content\/uploads\/2023\/08\/Screenshot_121.png 775w, https:\/\/crocoblock.com\/knowledge-base\/wp-content\/uploads\/2023\/08\/Screenshot_121-300x124.png 300w, https:\/\/crocoblock.com\/knowledge-base\/wp-content\/uploads\/2023\/08\/Screenshot_121-768x318.png 768w, https:\/\/crocoblock.com\/knowledge-base\/wp-content\/uploads\/2023\/08\/Screenshot_121-600x249.png 600w\" sizes=\"(max-width: 775px) 100vw, 775px\" \/><\/div>\n<\/div><\/div>\n\n\n\n<h2 class=\"wp-block-heading\" id=\"create-a-custom-query-with-one-set-of-query-clauses\">Create a Custom Query with One Set of Query Clauses<\/h2>\n\n\n\n<div class=\"wp-block-group is-layout-constrained wp-block-group-is-layout-constrained\"><div class=\"wp-block-group__inner-container\">\n<p>Next, we need to go to <strong><em>JetEngine > Query Builder<\/em><\/strong> and hit the <strong>\u201cAdd New\u201d<\/strong> button.\u00a0<\/p>\n\n\n\n<p>Type the <strong>Name<\/strong>. The <strong>Query Type <\/strong>should be \u201cUsers Query\u201d since the <strong>Switcher<\/strong> meta field has been created for users.<\/p>\n\n\n\n<div class=\"wp-block-image size-full\"><img loading=\"lazy\" decoding=\"async\" width=\"780\" height=\"445\" src=\"https:\/\/crocoblock.com\/knowledge-base\/wp-content\/uploads\/2023\/08\/Screenshot_122.png\" alt=\"user custom query creation\" class=\"wp-image-41516\" srcset=\"https:\/\/crocoblock.com\/knowledge-base\/wp-content\/uploads\/2023\/08\/Screenshot_122.png 780w, https:\/\/crocoblock.com\/knowledge-base\/wp-content\/uploads\/2023\/08\/Screenshot_122-300x171.png 300w, https:\/\/crocoblock.com\/knowledge-base\/wp-content\/uploads\/2023\/08\/Screenshot_122-768x438.png 768w, https:\/\/crocoblock.com\/knowledge-base\/wp-content\/uploads\/2023\/08\/Screenshot_122-150x85.png 150w, https:\/\/crocoblock.com\/knowledge-base\/wp-content\/uploads\/2023\/08\/Screenshot_122-600x342.png 600w\" sizes=\"(max-width: 780px) 100vw, 780px\" \/><\/div>\n\n\n\n<p>Next, open the <strong>Meta Query<\/strong> tab, and press the <strong>\u201cAdd New\u201d <\/strong>button to add a <strong>Meta Query Clause<\/strong>.\u00a0<\/p>\n\n\n\n<p>Enter the Switcher <strong>Field key\/name<\/strong>, select the \u201cEqual (=)\u201d option in the <strong>Compare <\/strong>field, enter the \u201ctrue\u201d <strong>Value<\/strong>, and pick the \u201cChar\u201d <strong>Type<\/strong>.\u00a0<\/p>\n\n\n\n<p>The Switcher has a \u201ctrue\u201d<strong> Value<\/strong> when enabled and a \u201cfalse\u201d <strong>Value<\/strong> when disabled. This clause means that the users with enabled switcher are pulled.<\/p>\n\n\n\n<div class=\"wp-block-image size-full\"><img loading=\"lazy\" decoding=\"async\" width=\"881\" height=\"607\" src=\"https:\/\/crocoblock.com\/knowledge-base\/wp-content\/uploads\/2023\/08\/Screenshot_123.png\" alt=\"meta query clause to pull users with enabled switcher\" class=\"wp-image-41517\" srcset=\"https:\/\/crocoblock.com\/knowledge-base\/wp-content\/uploads\/2023\/08\/Screenshot_123.png 881w, https:\/\/crocoblock.com\/knowledge-base\/wp-content\/uploads\/2023\/08\/Screenshot_123-300x207.png 300w, https:\/\/crocoblock.com\/knowledge-base\/wp-content\/uploads\/2023\/08\/Screenshot_123-768x529.png 768w, https:\/\/crocoblock.com\/knowledge-base\/wp-content\/uploads\/2023\/08\/Screenshot_123-600x413.png 600w\" sizes=\"(max-width: 881px) 100vw, 881px\" \/><\/div>\n\n\n\n<p>Now, you can click the <strong>\u201cAdd Query\u201d<\/strong> button to save this custom query.<\/p>\n<\/div><\/div>\n\n\n\n<h2 class=\"wp-block-heading\" id=\"create-a-custom-query-with-another-set-of-query-clauses\">Create a Custom Query with Another Set of Query Clauses<\/h2>\n\n\n\n<div class=\"wp-block-group is-layout-constrained wp-block-group-is-layout-constrained\"><div class=\"wp-block-group__inner-container\">\n<p>The next custom query is for pulling users with the disabled state of the <strong>Switcher<\/strong> meta field. You can <strong>copy<\/strong> the custom query created in the previous step and add the needed changes to the duplicated query.<\/p>\n\n\n\n<div class=\"wp-block-image size-full\"><img loading=\"lazy\" decoding=\"async\" width=\"812\" height=\"394\" src=\"https:\/\/crocoblock.com\/knowledge-base\/wp-content\/uploads\/2023\/08\/Screenshot_124.png\" alt=\"copy the custom query\" class=\"wp-image-41518\" srcset=\"https:\/\/crocoblock.com\/knowledge-base\/wp-content\/uploads\/2023\/08\/Screenshot_124.png 812w, https:\/\/crocoblock.com\/knowledge-base\/wp-content\/uploads\/2023\/08\/Screenshot_124-300x146.png 300w, https:\/\/crocoblock.com\/knowledge-base\/wp-content\/uploads\/2023\/08\/Screenshot_124-768x373.png 768w, https:\/\/crocoblock.com\/knowledge-base\/wp-content\/uploads\/2023\/08\/Screenshot_124-600x291.png 600w\" sizes=\"(max-width: 812px) 100vw, 812px\" \/><\/div>\n\n\n\n<p>We renamed the new custom query, went to the <strong>Meta Query <\/strong>tab, and edited the <strong>Value<\/strong> for the <strong>Meta Query Clause <\/strong>by Switcher to \u201cfalse.\u201d After that, the custom query can be saved.<\/p>\n\n\n\n<div class=\"wp-block-image size-full\"><img loading=\"lazy\" decoding=\"async\" width=\"837\" height=\"525\" src=\"https:\/\/crocoblock.com\/knowledge-base\/wp-content\/uploads\/2023\/08\/Screenshot_125.png\" alt=\"set the false value for the meta query clause\" class=\"wp-image-41519\" srcset=\"https:\/\/crocoblock.com\/knowledge-base\/wp-content\/uploads\/2023\/08\/Screenshot_125.png 837w, https:\/\/crocoblock.com\/knowledge-base\/wp-content\/uploads\/2023\/08\/Screenshot_125-300x188.png 300w, https:\/\/crocoblock.com\/knowledge-base\/wp-content\/uploads\/2023\/08\/Screenshot_125-768x482.png 768w, https:\/\/crocoblock.com\/knowledge-base\/wp-content\/uploads\/2023\/08\/Screenshot_125-600x376.png 600w\" sizes=\"(max-width: 837px) 100vw, 837px\" \/><\/div>\n<\/div><\/div>\n\n\n\n<h2 class=\"wp-block-heading\" id=\"create-a-sql-query-to-combine-two-custom-queries\">Create a SQL Query to Combine Two Custom Queries<\/h2>\n\n\n\n<div class=\"wp-block-group is-layout-constrained wp-block-group-is-layout-constrained\"><div class=\"wp-block-group__inner-container\">\n<p>The next custom query will combine the previous two queries. Create a new query, <strong>Name<\/strong> it, and select the \u201cSQL\/AI Query\u201d <strong>Type<\/strong>. Then, enable the <strong>Advanced\/AI mode <\/strong>toggle.<\/p>\n\n\n\n<div class=\"wp-block-image size-full\"><img loading=\"lazy\" decoding=\"async\" width=\"885\" height=\"648\" src=\"https:\/\/crocoblock.com\/knowledge-base\/wp-content\/uploads\/2023\/08\/Screenshot_127.png\" alt=\"SQL\/AI query type\" class=\"wp-image-41520\" srcset=\"https:\/\/crocoblock.com\/knowledge-base\/wp-content\/uploads\/2023\/08\/Screenshot_127.png 885w, https:\/\/crocoblock.com\/knowledge-base\/wp-content\/uploads\/2023\/08\/Screenshot_127-300x220.png 300w, https:\/\/crocoblock.com\/knowledge-base\/wp-content\/uploads\/2023\/08\/Screenshot_127-768x562.png 768w, https:\/\/crocoblock.com\/knowledge-base\/wp-content\/uploads\/2023\/08\/Screenshot_127-600x439.png 600w\" sizes=\"(max-width: 885px) 100vw, 885px\" \/><\/div>\n\n\n\n<p>In the <strong>SQL Query<\/strong> field, add the SQL snippet provided below. This SQL query combines items from two other queries. This way, users with the enabled Switcher are displayed first, and users with the disabled Switcher are shown second.<\/p>\n\n\n\n<pre class=\"wp-block-code\"><code>SELECT ID\n\nFROM {prefix}users\n\nWHERE ID IN (\n\n%query_results|135%{\"fallback\":\"'999999999'\"},\n\n%query_results|136%{\"fallback\":\"999999999\"}\n\n)\nORDER BY FIELD( \n   ID,\n %query_results|135%{\"fallback\":\"'999999999'\"},\n \n %query_results|136%{\"fallback\":\"999999999\"}\n)<\/code><\/pre>\n\n\n<div class=\"note-banner d-flex border-bold border-jetsmartfilters rounded overflow-hidden p-20\"><div class=\"mr-12\"><svg width=\"24\" height=\"24\" viewBox=\"0 0 24 24\" fill=\"none\" xmlns=\"http:\/\/www.w3.org\/2000\/svg\"><path d=\"M1 21H23L12 2L1 21ZM13 18H11V16H13V18ZM13 14H11V10H13V14Z\" fill=\"#FA5450\"\/><\/svg><\/div><div class=\"d-flex flex-column\"><div class=\"text-900 mb-12\">Warning<\/div><p class=\"m-0\">Note that \u201c135\u201d and \u201c136\u201d are IDs of the custom queries from which the results are pulled. These numbers need to be substituted with the IDs of the custom queries from your website.<\/p><\/div><\/div>\n\n\n\n<div class=\"wp-block-image size-full\"><img loading=\"lazy\" decoding=\"async\" width=\"884\" height=\"599\" src=\"https:\/\/crocoblock.com\/knowledge-base\/wp-content\/uploads\/2023\/08\/Screenshot_135.png\" alt=\"SQL snippet in the SQL query\" class=\"wp-image-41525\" srcset=\"https:\/\/crocoblock.com\/knowledge-base\/wp-content\/uploads\/2023\/08\/Screenshot_135.png 884w, https:\/\/crocoblock.com\/knowledge-base\/wp-content\/uploads\/2023\/08\/Screenshot_135-300x203.png 300w, https:\/\/crocoblock.com\/knowledge-base\/wp-content\/uploads\/2023\/08\/Screenshot_135-768x520.png 768w, https:\/\/crocoblock.com\/knowledge-base\/wp-content\/uploads\/2023\/08\/Screenshot_135-600x407.png 600w\" sizes=\"(max-width: 884px) 100vw, 884px\" \/><\/div>\n\n\n\n<p>The custom query ID can be found in the URL of the <strong>Edit Query<\/strong> page.<\/p>\n\n\n\n<div class=\"wp-block-image aligncenter size-full\"><img loading=\"lazy\" decoding=\"async\" width=\"693\" height=\"288\" src=\"https:\/\/crocoblock.com\/knowledge-base\/wp-content\/uploads\/2023\/08\/Screenshot_130.png\" alt=\"query ID on the edit query page\" class=\"wp-image-41521\" srcset=\"https:\/\/crocoblock.com\/knowledge-base\/wp-content\/uploads\/2023\/08\/Screenshot_130.png 693w, https:\/\/crocoblock.com\/knowledge-base\/wp-content\/uploads\/2023\/08\/Screenshot_130-300x125.png 300w, https:\/\/crocoblock.com\/knowledge-base\/wp-content\/uploads\/2023\/08\/Screenshot_130-600x249.png 600w\" sizes=\"(max-width: 693px) 100vw, 693px\" \/><\/div>\n\n\n\n<p>The <strong>fallback<\/strong> has the \u2018999999999\u2019 number because it must be a unique number that is not reserved by some instance, like post ID. If you want to use a <strong>fallback<\/strong> with a string value, you also need to add single quotes.<\/p>\n\n\n\n<p>Now the SQL query is completed, and you can hit the <strong>\u201cAdd\/Update Query\u201d <\/strong>button.<\/p>\n\n\n\n<h3 class=\"wp-block-heading\" id=\"sql-query-for-posts\">SQL query for posts<\/h3>\n\n\n\n<p>Let us provide an example of the SQL snippet in case the posts are queried instead of users.<\/p>\n\n\n\n<p>In this case, you need to write the \u201cposts\u201d table in the custom query instead of \u201cusers.\u201d<\/p>\n\n\n\n<pre class=\"wp-block-code\"><code>SELECT ID\r\n\r\nFROM {prefix}posts\r\n\r\nWHERE ID IN (\r\n\r\n%query_results|135%{\"fallback\":\"'999999999'\"},\r\n\r\n%query_results|136%{\"fallback\":\"999999999\"}\r\n\r\n)\r\nORDER BY FIELD( \r\n   ID,\r\n %query_results|135%{\"fallback\":\"'999999999'\"},\r\n \r\n%query_results|136%{\"fallback\":\"999999999\"}\r\n)\r<\/code><\/pre>\n<\/div><\/div>\n\n\n\n<h2 class=\"wp-block-heading\" id=\"create-a-custom-query-to-pull-combined-results-from-the-sql-query\">Create a Custom Query to Pull Combined Results from the SQL Query<\/h2>\n\n\n\n<div class=\"wp-block-group is-layout-constrained wp-block-group-is-layout-constrained\"><div class=\"wp-block-group__inner-container\"><div class=\"note-banner d-flex border-bold border-jetsmartfilters rounded overflow-hidden p-20\"><div class=\"mr-12\"><svg width=\"24\" height=\"24\" viewBox=\"0 0 24 24\" fill=\"none\" xmlns=\"http:\/\/www.w3.org\/2000\/svg\"><path d=\"M1 21H23L12 2L1 21ZM13 18H11V16H13V18ZM13 14H11V10H13V14Z\" fill=\"#FA5450\"\/><\/svg><\/div><div class=\"d-flex flex-column\"><div class=\"text-900 mb-12\">Warning<\/div><p class=\"m-0\">This step is required if the <strong>Listing Grid<\/strong> that uses this custom query needs to be filtered by the <em>JetSmartFilters<\/em> plugin.<\/p><\/div><\/div>\n\n\n\n<p>At this stage, we need to create another custom query in the <strong>Query Builder<\/strong>.<\/p>\n\n\n\n<p>A <strong>Listing Grid<\/strong> that uses the Advanced SQL custom query can not be filtered, so it is important to create another user, posts, etc. query which pulls all combined items from the Advanced SQL query.<\/p>\n\n\n\n<p>Therefore, add a new query, name it and select the \u201cUsers Query\u201d <strong>Type<\/strong>.<\/p>\n\n\n\n<div class=\"wp-block-image size-full\"><img loading=\"lazy\" decoding=\"async\" width=\"753\" height=\"459\" src=\"https:\/\/crocoblock.com\/knowledge-base\/wp-content\/uploads\/2023\/08\/Screenshot_131.png\" alt=\"custom query for filters\" class=\"wp-image-41522\" srcset=\"https:\/\/crocoblock.com\/knowledge-base\/wp-content\/uploads\/2023\/08\/Screenshot_131.png 753w, https:\/\/crocoblock.com\/knowledge-base\/wp-content\/uploads\/2023\/08\/Screenshot_131-300x183.png 300w, https:\/\/crocoblock.com\/knowledge-base\/wp-content\/uploads\/2023\/08\/Screenshot_131-600x366.png 600w\" sizes=\"(max-width: 753px) 100vw, 753px\" \/><\/div>\n\n\n\n<p>Then, proceed to the<strong> Include\/Exclude<\/strong> tab, click the <strong>coin-stack icon<\/strong>, and add the \u201cQuery Results\u201d macro into the<strong> Include<\/strong> field.<\/p>\n\n\n\n<p>For the \u201cQuery Results\u201d macro, select the Advanced SQL <strong>Query<\/strong> built in the previous step. Then pick the \u201cList of selected fields from item object\u201d option in the <strong>Return<\/strong> field, and write \u201cID\u201d into the <strong>Comma-separated fields list<\/strong>. Then, push the <strong>\u201cApply\u201d <\/strong>button.<\/p>\n\n\n\n<p>Now, this user query has a list of users combined in the SQL query.\u00a0<\/p>\n\n\n\n<div class=\"wp-block-image size-full\"><img loading=\"lazy\" decoding=\"async\" width=\"840\" height=\"499\" src=\"https:\/\/crocoblock.com\/knowledge-base\/wp-content\/uploads\/2023\/08\/Screenshot_133.png\" alt=\"Query Results macro\" class=\"wp-image-41523\" srcset=\"https:\/\/crocoblock.com\/knowledge-base\/wp-content\/uploads\/2023\/08\/Screenshot_133.png 840w, https:\/\/crocoblock.com\/knowledge-base\/wp-content\/uploads\/2023\/08\/Screenshot_133-300x178.png 300w, https:\/\/crocoblock.com\/knowledge-base\/wp-content\/uploads\/2023\/08\/Screenshot_133-768x456.png 768w, https:\/\/crocoblock.com\/knowledge-base\/wp-content\/uploads\/2023\/08\/Screenshot_133-600x356.png 600w\" sizes=\"(max-width: 840px) 100vw, 840px\" \/><\/div>\n\n\n\n<p>Next, go to the <strong>Misc<\/strong> tab, and pick the \u201cBy the included list of user IDs (requires the Include parameter)\u201d option in the <strong>Order by <\/strong>field. This order will ensure the users with enabled Switcher meta field are displayed first, and users with disabled Switcher are shown afterward.<\/p>\n\n\n\n<div class=\"wp-block-image size-full\"><img loading=\"lazy\" decoding=\"async\" width=\"884\" height=\"703\" src=\"https:\/\/crocoblock.com\/knowledge-base\/wp-content\/uploads\/2023\/08\/Screenshot_136.png\" alt=\"order by the included list of user IDs\" class=\"wp-image-41526\" srcset=\"https:\/\/crocoblock.com\/knowledge-base\/wp-content\/uploads\/2023\/08\/Screenshot_136.png 884w, https:\/\/crocoblock.com\/knowledge-base\/wp-content\/uploads\/2023\/08\/Screenshot_136-300x239.png 300w, https:\/\/crocoblock.com\/knowledge-base\/wp-content\/uploads\/2023\/08\/Screenshot_136-768x611.png 768w, https:\/\/crocoblock.com\/knowledge-base\/wp-content\/uploads\/2023\/08\/Screenshot_136-600x477.png 600w\" sizes=\"(max-width: 884px) 100vw, 884px\" \/><\/div>\n\n\n\n<p>Now, you can hit the <strong>\u201cAdd\/Update Query\u201d <\/strong>button.<\/p>\n\n\n\n<h2 class=\"wp-block-heading\" id=\"create-a-listing-for-users\">Create a Listing for Users<\/h2>\n\n\n\n<p>Go to <strong><em>JetEngine > Listings<\/em><\/strong> and click the <strong>\u201cAdd New\u201d<\/strong> button. Select \u201cUsers\u201d as the <strong>Listing source<\/strong>, enter the <strong>Listing item name<\/strong>, and pick the \u201cElementor\u201d or \u201cBlocks (Gutenberg)\u201d <strong>Listing view<\/strong>. Then, click the <strong>\u201cCreate Listing Item\u201d <\/strong>button.<\/p>\n\n\n\n<div class=\"wp-block-image aligncenter size-full\"><img loading=\"lazy\" decoding=\"async\" width=\"667\" height=\"414\" src=\"https:\/\/crocoblock.com\/knowledge-base\/wp-content\/uploads\/2023\/08\/Screenshot_134.png\" alt=\"setup listing item for users\" class=\"wp-image-41524\" srcset=\"https:\/\/crocoblock.com\/knowledge-base\/wp-content\/uploads\/2023\/08\/Screenshot_134.png 667w, https:\/\/crocoblock.com\/knowledge-base\/wp-content\/uploads\/2023\/08\/Screenshot_134-300x186.png 300w, https:\/\/crocoblock.com\/knowledge-base\/wp-content\/uploads\/2023\/08\/Screenshot_134-600x372.png 600w\" sizes=\"(max-width: 667px) 100vw, 667px\" \/><\/div>\n\n\n\n<p>In the Listing template editing page, you can add the <a href=\"https:\/\/crocoblock.com\/knowledge-base\/jetengine\/dynamic-field-widget-overview\/\"><strong>Dynamic Field<\/strong><\/a> widget or block to show the user data. We added the <strong>Dynamic Field<\/strong> to display some text based on the state of the <strong>Switcher<\/strong> meta field. Select the \u201cMeta Data\u201d as the <strong>Source<\/strong>, and pick the switcher <strong>Meta Field<\/strong> from the user Meta Box.<\/p>\n\n\n\n<p>To show the different text based on the value of the <strong>Switcher<\/strong> meta field, enable the <strong>Filter field output <\/strong>toggle. Select the \u201cSwitcher field values\u201d as the <strong>Callback<\/strong>.\u00a0<\/p>\n\n\n\n<div class=\"wp-block-image aligncenter size-full is-style-default\"><img loading=\"lazy\" decoding=\"async\" width=\"400\" height=\"838\" src=\"https:\/\/crocoblock.com\/knowledge-base\/wp-content\/uploads\/2023\/08\/Screenshot_137.png\" alt=\"switcher field values callback\" class=\"wp-image-41527\" srcset=\"https:\/\/crocoblock.com\/knowledge-base\/wp-content\/uploads\/2023\/08\/Screenshot_137.png 400w, https:\/\/crocoblock.com\/knowledge-base\/wp-content\/uploads\/2023\/08\/Screenshot_137-143x300.png 143w\" sizes=\"(max-width: 400px) 100vw, 400px\" \/><\/div>\n\n\n\n<p>Then, add a needed text for each state into the <strong>Text if enabled <\/strong>and <strong>Text is disabled <\/strong>fields. In our case, the \u201cThis user is verified!\u201d text will appear when the user has the switcher in the enabled state, and the \u2019This user is unverified.\u2019 text will be shown when the user has the switcher in the disabled state.<\/p>\n\n\n\n<div class=\"wp-block-image aligncenter size-full\"><img loading=\"lazy\" decoding=\"async\" width=\"394\" height=\"479\" src=\"https:\/\/crocoblock.com\/knowledge-base\/wp-content\/uploads\/2023\/08\/Screenshot_138.png\" alt=\"text for the enabled and disabled switcher states\" class=\"wp-image-41528\" srcset=\"https:\/\/crocoblock.com\/knowledge-base\/wp-content\/uploads\/2023\/08\/Screenshot_138.png 394w, https:\/\/crocoblock.com\/knowledge-base\/wp-content\/uploads\/2023\/08\/Screenshot_138-247x300.png 247w\" sizes=\"(max-width: 394px) 100vw, 394px\" \/><\/div>\n\n\n\n<p>At this point, the Listing template can be saved by clicking the <strong>\u201cUpdate\u201d <\/strong>button.<\/p>\n<\/div><\/div>\n\n\n\n<h2 class=\"wp-block-heading\" id=\"output-the-listing-on-the-front-end\">Output the Listing on the Front End<\/h2>\n\n\n\n<div class=\"wp-block-group is-layout-constrained wp-block-group-is-layout-constrained\"><div class=\"wp-block-group__inner-container\">\n<p>Now, you can add the <strong>Listing Grid<\/strong> widget or block to the needed page and select the <strong>Listing<\/strong> template for Users that has just been created in the <strong>General <\/strong>settings tab.<\/p>\n\n\n\n<div class=\"wp-block-image aligncenter size-full\"><img loading=\"lazy\" decoding=\"async\" width=\"877\" height=\"402\" src=\"https:\/\/crocoblock.com\/knowledge-base\/wp-content\/uploads\/2023\/08\/Screenshot_139.png\" alt=\"Listing Grid with the Listing template for users\" class=\"wp-image-41529\" srcset=\"https:\/\/crocoblock.com\/knowledge-base\/wp-content\/uploads\/2023\/08\/Screenshot_139.png 877w, https:\/\/crocoblock.com\/knowledge-base\/wp-content\/uploads\/2023\/08\/Screenshot_139-300x138.png 300w, https:\/\/crocoblock.com\/knowledge-base\/wp-content\/uploads\/2023\/08\/Screenshot_139-768x352.png 768w, https:\/\/crocoblock.com\/knowledge-base\/wp-content\/uploads\/2023\/08\/Screenshot_139-600x275.png 600w\" sizes=\"(max-width: 877px) 100vw, 877px\" \/><\/div>\n\n\n\n<p>Open the <strong>Custom Query <\/strong>tab, enable the <strong>Use Custom Query <\/strong>toggle, and select the lastly created <strong>Custom Query <\/strong>to keep the Users in the desired order.<\/p>\n\n\n\n<div class=\"wp-block-image size-full\"><img loading=\"lazy\" decoding=\"async\" width=\"872\" height=\"414\" src=\"https:\/\/crocoblock.com\/knowledge-base\/wp-content\/uploads\/2023\/08\/Screenshot_140.png\" alt=\"enable the custom query for the Listing Grid\" class=\"wp-image-41530\" srcset=\"https:\/\/crocoblock.com\/knowledge-base\/wp-content\/uploads\/2023\/08\/Screenshot_140.png 872w, https:\/\/crocoblock.com\/knowledge-base\/wp-content\/uploads\/2023\/08\/Screenshot_140-300x142.png 300w, https:\/\/crocoblock.com\/knowledge-base\/wp-content\/uploads\/2023\/08\/Screenshot_140-768x365.png 768w, https:\/\/crocoblock.com\/knowledge-base\/wp-content\/uploads\/2023\/08\/Screenshot_140-600x285.png 600w\" sizes=\"(max-width: 872px) 100vw, 872px\" \/><\/div>\n\n\n\n<p>Let us save the page by clicking the <strong>\u201cUpdate\u201d <\/strong>button and check the result on the front end.<\/p>\n\n\n\n<p>We can see the desired result is achieved. Firstly, the users with the enabled switcher are displayed, and then the users with the disabled switcher.<\/p>\n\n\n\n<div class=\"wp-block-image size-full\"><img loading=\"lazy\" decoding=\"async\" width=\"734\" height=\"383\" src=\"https:\/\/crocoblock.com\/knowledge-base\/wp-content\/uploads\/2023\/08\/Screenshot_141.png\" alt=\"listing with the combined custom queries on the front end\" class=\"wp-image-41531\" srcset=\"https:\/\/crocoblock.com\/knowledge-base\/wp-content\/uploads\/2023\/08\/Screenshot_141.png 734w, https:\/\/crocoblock.com\/knowledge-base\/wp-content\/uploads\/2023\/08\/Screenshot_141-300x157.png 300w, https:\/\/crocoblock.com\/knowledge-base\/wp-content\/uploads\/2023\/08\/Screenshot_141-600x313.png 600w\" sizes=\"(max-width: 734px) 100vw, 734px\" \/><\/div>\n<\/div><\/div>\n\n\n\n<p>That is all. Now you know how to combine multiple custom queries into one to arrange an advanced order in the <strong>Listing Grid<\/strong> widget or block with the <em>JetEngine <\/em>WordPress plugin.<\/p>\n","protected":false},"excerpt":{"rendered":"<p>This tutorial covers the topic of using Query Builder to show results from more than one query in just one Listing Grid.<\/p>\n","protected":false},"author":8,"featured_media":0,"template":"","format":"standard","builder-category":[],"article-category":[405],"yoast_head":"<!-- This site is optimized with the Yoast SEO plugin v20.9 - https:\/\/yoast.com\/wordpress\/plugins\/seo\/ -->\n<title>How to Combine Results of Multiple Custom Queries into One Custom Query | Crocoblock<\/title>\n<meta name=\"description\" content=\"This tutorial describes how to use Query Builder to show results from more than one query in one JetEngine Listing Grid.\" \/>\n<meta name=\"robots\" content=\"index, follow, max-snippet:-1, max-image-preview:large, max-video-preview:-1\" \/>\n<link rel=\"canonical\" href=\"https:\/\/crocoblock.com\/knowledge-base\/jetengine\/combining-results-of-multiple-custom-queries\/\" \/>\n<meta property=\"og:locale\" content=\"en_US\" \/>\n<meta property=\"og:type\" content=\"article\" \/>\n<meta property=\"og:title\" content=\"How to Combine Results of Multiple Custom Queries into One Custom Query | Crocoblock\" \/>\n<meta property=\"og:description\" content=\"This tutorial describes how to use Query Builder to show results from more than one query in one JetEngine Listing Grid.\" \/>\n<meta property=\"og:url\" content=\"https:\/\/crocoblock.com\/knowledge-base\/jetengine\/combining-results-of-multiple-custom-queries\/\" \/>\n<meta property=\"og:site_name\" content=\"Help Center\" \/>\n<meta property=\"article:modified_time\" content=\"2024-06-21T09:15:29+00:00\" \/>\n<meta property=\"og:image\" content=\"https:\/\/crocoblock.com\/knowledge-base\/wp-content\/uploads\/2023\/08\/Screenshot_120.png\" \/>\n<meta name=\"twitter:card\" content=\"summary_large_image\" \/>\n<meta name=\"twitter:label1\" content=\"Est. reading time\" \/>\n\t<meta name=\"twitter:data1\" content=\"10 minutes\" \/>\n<script type=\"application\/ld+json\" class=\"yoast-schema-graph\">{\"@context\":\"https:\/\/schema.org\",\"@graph\":[{\"@type\":\"WebPage\",\"@id\":\"https:\/\/crocoblock.com\/knowledge-base\/jetengine\/combining-results-of-multiple-custom-queries\/\",\"url\":\"https:\/\/crocoblock.com\/knowledge-base\/jetengine\/combining-results-of-multiple-custom-queries\/\",\"name\":\"How to Combine Results of Multiple Custom Queries into One Custom Query | Crocoblock\",\"isPartOf\":{\"@id\":\"https:\/\/crocoblock.com\/knowledge-base\/#website\"},\"datePublished\":\"2023-08-09T16:49:51+00:00\",\"dateModified\":\"2024-06-21T09:15:29+00:00\",\"description\":\"This tutorial describes how to use Query Builder to show results from more than one query in one JetEngine Listing Grid.\",\"breadcrumb\":{\"@id\":\"https:\/\/crocoblock.com\/knowledge-base\/jetengine\/combining-results-of-multiple-custom-queries\/#breadcrumb\"},\"inLanguage\":\"en-US\",\"potentialAction\":[{\"@type\":\"ReadAction\",\"target\":[\"https:\/\/crocoblock.com\/knowledge-base\/jetengine\/combining-results-of-multiple-custom-queries\/\"]}]},{\"@type\":\"BreadcrumbList\",\"@id\":\"https:\/\/crocoblock.com\/knowledge-base\/jetengine\/combining-results-of-multiple-custom-queries\/#breadcrumb\",\"itemListElement\":[{\"@type\":\"ListItem\",\"position\":1,\"name\":\"Home\",\"item\":\"https:\/\/crocoblock.com\/knowledge-base\/\"},{\"@type\":\"ListItem\",\"position\":2,\"name\":\"Articles\",\"item\":\"https:\/\/crocoblock.com\/knowledge-base\/articles\/\"},{\"@type\":\"ListItem\",\"position\":3,\"name\":\"How to Combine Results of Multiple Custom Queries into One Custom Query\"}]},{\"@type\":\"WebSite\",\"@id\":\"https:\/\/crocoblock.com\/knowledge-base\/#website\",\"url\":\"https:\/\/crocoblock.com\/knowledge-base\/\",\"name\":\"Help Center\",\"description\":\"\",\"publisher\":{\"@id\":\"https:\/\/crocoblock.com\/knowledge-base\/#organization\"},\"potentialAction\":[{\"@type\":\"SearchAction\",\"target\":{\"@type\":\"EntryPoint\",\"urlTemplate\":\"https:\/\/crocoblock.com\/knowledge-base\/?s={search_term_string}\"},\"query-input\":\"required name=search_term_string\"}],\"inLanguage\":\"en-US\"},{\"@type\":\"Organization\",\"@id\":\"https:\/\/crocoblock.com\/knowledge-base\/#organization\",\"name\":\"Help Center\",\"url\":\"https:\/\/crocoblock.com\/knowledge-base\/\",\"logo\":{\"@type\":\"ImageObject\",\"inLanguage\":\"en-US\",\"@id\":\"https:\/\/crocoblock.com\/knowledge-base\/#\/schema\/logo\/image\/\",\"url\":\"https:\/\/crocoblock.com\/knowledge-base\/wp-content\/uploads\/2025\/04\/invert-crocoblock-logo.svg\",\"contentUrl\":\"https:\/\/crocoblock.com\/knowledge-base\/wp-content\/uploads\/2025\/04\/invert-crocoblock-logo.svg\",\"caption\":\"Help Center\"},\"image\":{\"@id\":\"https:\/\/crocoblock.com\/knowledge-base\/#\/schema\/logo\/image\/\"}}]}<\/script>\n<!-- \/ Yoast SEO plugin. -->","yoast_head_json":{"title":"How to Combine Results of Multiple Custom Queries into One Custom Query | Crocoblock","description":"This tutorial describes how to use Query Builder to show results from more than one query in one JetEngine Listing Grid.","robots":{"index":"index","follow":"follow","max-snippet":"max-snippet:-1","max-image-preview":"max-image-preview:large","max-video-preview":"max-video-preview:-1"},"canonical":"https:\/\/crocoblock.com\/knowledge-base\/jetengine\/combining-results-of-multiple-custom-queries\/","og_locale":"en_US","og_type":"article","og_title":"How to Combine Results of Multiple Custom Queries into One Custom Query | Crocoblock","og_description":"This tutorial describes how to use Query Builder to show results from more than one query in one JetEngine Listing Grid.","og_url":"https:\/\/crocoblock.com\/knowledge-base\/jetengine\/combining-results-of-multiple-custom-queries\/","og_site_name":"Help Center","article_modified_time":"2024-06-21T09:15:29+00:00","og_image":[{"url":"https:\/\/crocoblock.com\/knowledge-base\/wp-content\/uploads\/2023\/08\/Screenshot_120.png"}],"twitter_card":"summary_large_image","twitter_misc":{"Est. reading time":"10 minutes"},"schema":{"@context":"https:\/\/schema.org","@graph":[{"@type":"WebPage","@id":"https:\/\/crocoblock.com\/knowledge-base\/jetengine\/combining-results-of-multiple-custom-queries\/","url":"https:\/\/crocoblock.com\/knowledge-base\/jetengine\/combining-results-of-multiple-custom-queries\/","name":"How to Combine Results of Multiple Custom Queries into One Custom Query | Crocoblock","isPartOf":{"@id":"https:\/\/crocoblock.com\/knowledge-base\/#website"},"datePublished":"2023-08-09T16:49:51+00:00","dateModified":"2024-06-21T09:15:29+00:00","description":"This tutorial describes how to use Query Builder to show results from more than one query in one JetEngine Listing Grid.","breadcrumb":{"@id":"https:\/\/crocoblock.com\/knowledge-base\/jetengine\/combining-results-of-multiple-custom-queries\/#breadcrumb"},"inLanguage":"en-US","potentialAction":[{"@type":"ReadAction","target":["https:\/\/crocoblock.com\/knowledge-base\/jetengine\/combining-results-of-multiple-custom-queries\/"]}]},{"@type":"BreadcrumbList","@id":"https:\/\/crocoblock.com\/knowledge-base\/jetengine\/combining-results-of-multiple-custom-queries\/#breadcrumb","itemListElement":[{"@type":"ListItem","position":1,"name":"Home","item":"https:\/\/crocoblock.com\/knowledge-base\/"},{"@type":"ListItem","position":2,"name":"Articles","item":"https:\/\/crocoblock.com\/knowledge-base\/articles\/"},{"@type":"ListItem","position":3,"name":"How to Combine Results of Multiple Custom Queries into One Custom Query"}]},{"@type":"WebSite","@id":"https:\/\/crocoblock.com\/knowledge-base\/#website","url":"https:\/\/crocoblock.com\/knowledge-base\/","name":"Help Center","description":"","publisher":{"@id":"https:\/\/crocoblock.com\/knowledge-base\/#organization"},"potentialAction":[{"@type":"SearchAction","target":{"@type":"EntryPoint","urlTemplate":"https:\/\/crocoblock.com\/knowledge-base\/?s={search_term_string}"},"query-input":"required name=search_term_string"}],"inLanguage":"en-US"},{"@type":"Organization","@id":"https:\/\/crocoblock.com\/knowledge-base\/#organization","name":"Help Center","url":"https:\/\/crocoblock.com\/knowledge-base\/","logo":{"@type":"ImageObject","inLanguage":"en-US","@id":"https:\/\/crocoblock.com\/knowledge-base\/#\/schema\/logo\/image\/","url":"https:\/\/crocoblock.com\/knowledge-base\/wp-content\/uploads\/2025\/04\/invert-crocoblock-logo.svg","contentUrl":"https:\/\/crocoblock.com\/knowledge-base\/wp-content\/uploads\/2025\/04\/invert-crocoblock-logo.svg","caption":"Help Center"},"image":{"@id":"https:\/\/crocoblock.com\/knowledge-base\/#\/schema\/logo\/image\/"}}]}},"_links":{"self":[{"href":"https:\/\/crocoblock.com\/knowledge-base\/wp-json\/wp\/v2\/article\/41513"}],"collection":[{"href":"https:\/\/crocoblock.com\/knowledge-base\/wp-json\/wp\/v2\/article"}],"about":[{"href":"https:\/\/crocoblock.com\/knowledge-base\/wp-json\/wp\/v2\/types\/article"}],"author":[{"embeddable":true,"href":"https:\/\/crocoblock.com\/knowledge-base\/wp-json\/wp\/v2\/users\/8"}],"wp:attachment":[{"href":"https:\/\/crocoblock.com\/knowledge-base\/wp-json\/wp\/v2\/media?parent=41513"}],"wp:term":[{"taxonomy":"builder-category","embeddable":true,"href":"https:\/\/crocoblock.com\/knowledge-base\/wp-json\/wp\/v2\/builder-category?post=41513"},{"taxonomy":"article-category","embeddable":true,"href":"https:\/\/crocoblock.com\/knowledge-base\/wp-json\/wp\/v2\/article-category?post=41513"}],"curies":[{"name":"wp","href":"https:\/\/api.w.org\/{rel}","templated":true}]}}