bricks_add_query_filter
Overview
Add a query filter element to a page that lets users filter query loop results interactively. Supports 8 filter types: checkbox, datepicker, radio, range slider, search, select dropdown, submit button, and active filters display.
Each filter element connects to a specific query loop via the target_query_id parameter, and filters results based on taxonomy terms, custom fields, post meta, or WordPress fields. Filters update the query results via AJAX or page reload.
Key Features
When to Use
Creating price range sliders for product listings
Adding search input fields that filter query loop results
Building faceted navigation with multiple filter types (checkbox + range + search)
Displaying active filter pills that users can click to remove
enableQueryFilters must be enabled in Bricks global settings (via bricks_update_site_settings)
For taxonomy filters: the taxonomy must exist with terms assigned to posts
For custom field filters: posts must have the meta key populated
When NOT to Use
You need complex multi-step filtering logic — use a custom PHP query handler instead
The page has no query loops to filter
Parameters
page_idnumberREQUIREDparent_idstringoptionalfilter_typestringREQUIREDfilter-checkbox, filter-datepicker, filter-radio, filter-range, filter-search, filter-select, filter-submit, filter-active-filterstarget_query_idstringREQUIREDsettings.filterSourcestringoptionaltaxonomy, custom_field, post_meta, wp_fieldsettings.filterTaxonomystringoptionalsettings.filterMetaKeystringoptionalsettings.filterApplyOnstringoptionalchange Values: change, submitsettings.filterShowCountbooleanoptionalsettings.filterHideEmptybooleanoptionalcontent_areastringoptionalcontent Values: content, header, footerCode Examples
Warning: Undefined array key "example_output" in /var/www/vhosts/mcpbricksbuilder.wecode.swiss/httpdocs/wp-content/themes/bricks/includes/elements/code.php(236) : eval()'d code on line 12
Add category filter checkboxes to a blog grid
Create checkbox filters that let users filter blog posts by category, with post counts and AJAX updates.
bricks_add_query_filter({
page_id: 45,
parent_id: "filters-container",
filter_type: "filter-checkbox",
target_query_id: "blog-loop-item",
settings: {
filterSource: "taxonomy",
filterTaxonomy: "category",
filterLabel: "Categories",
filterShowCount: true,
filterHideEmpty: true,
filterApplyOn: "change"
}
});Common Mistakes
Warning: Undefined array key "fix_description" in /var/www/vhosts/mcpbricksbuilder.wecode.swiss/httpdocs/wp-content/themes/bricks/includes/elements/code.php(236) : eval()'d code on line 47
Deprecated: preg_replace(): Passing null to parameter #3 ($subject) of type array|string is deprecated in /var/www/vhosts/mcpbricksbuilder.wecode.swiss/httpdocs/wp-includes/kses.php on line 2018
Warning: Undefined array key "wrong_code" in /var/www/vhosts/mcpbricksbuilder.wecode.swiss/httpdocs/wp-content/themes/bricks/includes/elements/code.php(236) : eval()'d code on line 48
Warning: Undefined array key "right_code" in /var/www/vhosts/mcpbricksbuilder.wecode.swiss/httpdocs/wp-content/themes/bricks/includes/elements/code.php(236) : eval()'d code on line 49
Warning: Undefined array key "fix_description" in /var/www/vhosts/mcpbricksbuilder.wecode.swiss/httpdocs/wp-content/themes/bricks/includes/elements/code.php(236) : eval()'d code on line 47
Deprecated: preg_replace(): Passing null to parameter #3 ($subject) of type array|string is deprecated in /var/www/vhosts/mcpbricksbuilder.wecode.swiss/httpdocs/wp-includes/kses.php on line 2018
Warning: Undefined array key "wrong_code" in /var/www/vhosts/mcpbricksbuilder.wecode.swiss/httpdocs/wp-content/themes/bricks/includes/elements/code.php(236) : eval()'d code on line 48
Warning: Undefined array key "right_code" in /var/www/vhosts/mcpbricksbuilder.wecode.swiss/httpdocs/wp-content/themes/bricks/includes/elements/code.php(236) : eval()'d code on line 49
Tips & Warnings
Enable query filters first via bricks_update_site_settings({ enableQueryFilters: true }) before adding any filter elements.
Run bricks_reindex_filters after bulk content changes to ensure filter counts are accurate.
Combine multiple filter types for faceted navigation — e.g., checkbox for categories, range for price, search for text. All targeting the same query loop.