Skip to content
Help Center
  • Pricing
  • ProductsExpand
    • Premium BundlesGet all the tools you need in one bundle
    • Kadence ThemeLightning-fast performance theme for modern websites
    • Kadence BlocksDrop in ready designs with advanced controls for pixel perfect websites
    • Kadence Shop KitCreate a more effective WooCommerce shopping experience
    • Kadence ConversionsBoost sales and build engaged audiences with popups and banners
    • Kadence InsightsEasily create A/B tests. Optimize your pages to drive higher conversions.
    • View All Products
  • AI Starter Templates
  • Blog
  • SupportExpand
    • Help CenterProduct Questions? Not sure how to do something? Start here
    • Support TicketsNeed help? We love to help our customers
    • About usCrafted with love in Missoula, Montana
    • Contact usPre Sale Questions? Need help purchasing?
Account Account
Get Kadence
Kadence Blocks
  • Features
  • Pro
  • Blocks
  • HelpExpand
    • Documentation
    • Submit a Ticket
    • Facebook Group
    • Feature Requests
    • Roadmap
    • Changelog
Help Center
Kadence Blocks

Kadence Blocks

  • Table (Adv) Block
  • Create a Full Screen Landing Page
  • How to use Popup Modal Filters with Advanced Query Loops
  • Integrating Kadence Forms with Mailchimp
  • Site Identity Block
  • Search (Adv) Block
  • Using Advanced Header / Navigation Blocks vs Kadence Theme Header Builder
  • The Kadence Visual Builder & Off Canvas Settings
  • The Kadence Navigation (Adv) Block
  • The Kadence Navigation Link Block
  • The Kadence Header (Adv) Block
  • Google Maps Block
  • Integrating Kadence Forms with Mailerlite
  • Repeater Block
  • Accordion Block
  • Progress Bar Block
  • Form (Adv) Block
  • Gallery (Adv) Block
  • Section Block
  • Product Carousel Block
  • Image (Adv) Block
  • Buttons (Adv) Block
  • Count Up Block
  • Table of Contents Block
  • Lottie Animation Block
  • Show More Block
  • Posts Block
  • Countdown Block
  • Tabs Block
  • Row Layout Block
  • Form Block
  • Info Box Block
  • Spacer/Divider Block
  • Icon Block
  • Icon List Block
  • Text (Adv) Block
  • Testimonial Block

Getting Started

  • Kadence AI-Powered Design Library
  • Installing Kadence Blocks
  • Setting custom widths in multi-column Row Layout Blocks
  • How to define a color Palette with Kadence Blocks
  • How to delete/remove a Block
  • How to Duplicate and Copy/Paste Block Styles
  • Setting Block Defaults
  • Kadence Blocks Pexels Integration

Block Tutorials

  • Responsive Breakpoints in Kadence
  • How to use Popup Modal Filters with Advanced Query Loops
  • Using GIFS and Lottie Animations with Kadence Blocks
  • Search (Adv) Block
  • Displaying Shortcodes in the WordPress Editor
  • Integrating Kadence Forms with Mailchimp
  • Advanced Navigation Sub Menus and Mega Menus
  • Building Headers and Footers in Full Site Editing with Kadence Blocks
  • Creating Sticky and Transparent Advanced Headers
  • Getting started with Advanced Header/Navigations
  • Integrating Kadence Forms with Mailerlite
  • Split Content Quick Start Guide
  • How to control the Kadence Design Library
  • Adding Video Backgrounds to Row Layout
  • Pexels Picker
  • Adding Old Wireframes, Starter Packs, and Sections to the New Design Library
  • How to customize the design library color palette
  • Adding a Fullwidth Row
  • Adding Privacy Policy link to Kadence Form
  • Set Equal Column Heights with the Row Layout Block
  • Image Overlay Quick Start Guide
  • Modal Block Quick Start Guide

Pro Addon

  • Custom Queries for Advanced Query Loop Block
  • Kadence Blocks Pro Plugin
  • Advanced Slider
  • Video Popup Block
  • Image Overlay Block
  • Split Content Block
  • Modal Block
  • Dynamic Content
  • Query Loop (Adv) Block
  • Repeater Block
  • Using a Dynamic List Block
  • Dynamic Content: Custom Input and Showing Fields from all Post Types
  • How to Design a Post Grid/Carousel using a Kadence Element
  • Dynamic HTML Block
  • Using Custom SVG Icons with Kadence Blocks
  • Post/Grid Carousel Block
  • Kadence Custom Fonts
  • Post Grid/Carousel Block – Configure a Blog List

Troubleshooting Blocks

  • How to Recover a Broken Block

Advanced

  • Prebuilt Layouts
  • Using Tooltips with Kadence Blocks
  • Custom Queries for Advanced Query Loop Block
  • Adding a Custom Font to Kadence Blocks

Advanced Headers

  • Importing & Exporting Advanced Headers & Navigations
  • The Kadence Header (Adv) Block
  • The Kadence Navigation (Adv) Block
  • The Kadence Navigation Link Block
  • Getting started with Advanced Header/Navigations
  • Getting the most out of Navigation Link Blocks
  • Using Advanced Header / Navigation Blocks vs Kadence Theme Header Builder
  • Creating Sticky and Transparent Advanced Headers
  • Advanced Navigation Sub Menus and Mega Menus
  • Advanced Header Best Practices
  • The Kadence Navigation Builder
  • The Kadence Visual Builder & Off Canvas Settings
  • Building Headers and Footers in Full Site Editing with Kadence Blocks
  • Home
  • Knowledge Base
  • Kadence Blocks
  • Kadence Blocks
  • Advanced

Custom Queries for Advanced Query Loop Block

The Advanced Query Loop block (Kadence Blocks Pro)provides settings to create a custom query loop. However, sometimes, you need to alter the query beyond the capabilities of the Advanced Query Loop’s settings. In these cases, you can add a code snippet to alter the WordPress Query object. You can add PHP code to your site using a plugin like Code Snippets or your functions.php file (in a child theme).

If you want to modify the query arguments, you can make use of the ‘kadence_blocks_pro_query_loop_query_vars‘ filter. Here is an example that implements the filter.

Examples

add_filter( 'kadence_blocks_pro_query_loop_query_vars', function( $query, $ql_query_meta, $ql_id ) {

   if ( $ql_id == 5283 ) {
      $query['tax_query'] = array(
         array(
            'taxonomy' => 'category',
            'field' => 'slug',
            'terms' => 'sub',
         )
      );
   }
   
   return $query;
}, 10, 3 );

In the above code, the $ql_id is set to 5283. This is the post ID of the specific query you want to target. If you don’t provide the conditional “if” statement to target a query ID, all of your queries will share the arguments, which isn’t ideal. Among other ways, you can find the $ql_id by navigating to Kadence Blocks > All Queries, hovering over the edit link of your desired query, and looking at the bottom left corner of your browser window. Be sure to change the ID to suit your needs.

Query Post ID

The example also uses the Simple Taxonomy Query provided by the WordPress Query documentation. Here are some additional examples that have been modified from the WordPress documentation.

Returns posts dated December 12, 2012

Source: https://developer.wordpress.org/reference/classes/wp_query/#date-parameters

add_filter( 'kadence_blocks_pro_query_loop_query_vars', function( $query, $ql_query_meta, $ql_id ) {

   if ( $ql_id == 5283 ) {


      $query['date_query'] = array(
         array(
            'year' => 2012,
            'month' => 12,
            'day' => 12,
         ),
      );
   }
   
   return $query;
}, 10, 3 );

Display posts where the custom field key is ‘color’ and the custom field value IS ‘blue’:

Source: https://developer.wordpress.org/reference/classes/wp_query/#custom-field-post-meta-parameters

add_filter( 'kadence_blocks_pro_query_loop_query_vars', function( $query, $ql_query_meta, $ql_id ) {

   if ( $ql_id == 5283 ) {


      $query['meta_key'] = 'color';
      $query['meta_value'] = 'blue';
      $query['meta_compare'] = '=';
   }
   
   return $query;
}, 10, 3 );

Display posts with 25 comments or more:

Source: https://developer.wordpress.org/reference/classes/wp_query/#comment-parameters.

add_filter( 'kadence_blocks_pro_query_loop_query_vars', function( $query, $ql_query_meta, $ql_id ) {

   if ( $ql_id == 5283 ) {
      $query['post_type'] = 'post';
      $query['comment_count'] = array(
         'value' => 1,
         'compare' => '>=',
      );
   }
   
   return $query;
}, 10, 3 );

Display post that are not in a specific category:

Source: https://developer.wordpress.org/reference/classes/wp_query/#category-parameters

add_filter( 'kadence_blocks_pro_query_loop_query_vars', function( $query, $ql_query_meta, $ql_id ) {

   if ( $ql_id == 5283 ) {
      $query['category__not_in'] = 5;
   }	
   
   return $query;
}, 10, 3 );
Using Tooltips with Kadence Blocks
  • Pricing
  • Products
    • Premium BundlesGet all the tools you need in one bundle
    • Kadence ThemeLightning-fast performance theme for modern websites
    • Kadence BlocksDrop in ready designs with advanced controls for pixel perfect websites
    • Kadence Shop KitCreate a more effective WooCommerce shopping experience
    • Kadence ConversionsBoost sales and build engaged audiences with popups and banners
    • Kadence InsightsEasily create A/B tests. Optimize your pages to drive higher conversions.
    • View All Products
  • AI Starter Templates
  • Blog
  • Support
    • Help CenterProduct Questions? Not sure how to do something? Start here
    • Support TicketsNeed help? We love to help our customers
    • About usCrafted with love in Missoula, Montana
    • Contact usPre Sale Questions? Need help purchasing?
Account Login
  • Features
  • Pro
  • Blocks
  • HelpExpand
    • Documentation
    • Submit a Ticket
    • Facebook Group
    • Feature Requests
    • Roadmap
    • Changelog