bricks_reindex_filters

Phase 5BeginnerComplexity: 3/10
Rebuild the query filter index

Overview

Rebuild the Bricks query filter index tables to ensure accurate option counts and filter values. The filter index is a cached representation of filterable data that enables fast, accurate filter counts without running full queries on every page load.

The index can become stale after bulk content operations — importing posts, bulk editing meta fields, or adding/removing taxonomy terms. Running a reindex ensures all filter elements display correct counts and options.

Key Features

Selective Reindexing
Reindex all filter data, only taxonomy-based filters, or only custom field-based filters. Target the specific type that needs updating.
Accurate Counts
Rebuilds the cached count data so filter options show the correct number of matching posts for each term or meta value.

When to Use

After importing a large number of posts or products (e.g., WooCommerce CSV import)
After bulk editing taxonomy terms or custom fields across many posts
When filter counts appear incorrect or outdated
After creating multiple posts with bricks_create_post in a batch script
As a maintenance step during site deployment or content migration
Prerequisites
Query filters must be enabled in Bricks site settings (enableQueryFilters)
Filter elements must exist on at least one page
Posts with taxonomy terms or meta fields must exist for the index to build from

When NOT to Use

After creating a single post — Bricks typically updates the index automatically for individual changes
There are no query filter elements on the site — reindexing has no effect without filters
As a troubleshooting step for non-filter issues

Parameters

1 Total Parameters1 Optional
filter_typestringoptional
Which filter type to reindex. Use "all" to rebuild everything, or target a specific type.
Default: all Values: all, taxonomy, custom_field

Code 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

Reindex all filters after bulk content import

After importing 100 products with taxonomy terms and price meta fields, rebuild the entire filter index.

JSON
// Reindex everything
bricks_reindex_filters({ filter_type: "all" });

// Or just taxonomy filters after adding new categories
bricks_reindex_filters({ filter_type: "taxonomy" });

// Or just custom field filters after bulk meta updates
bricks_reindex_filters({ filter_type: "custom_field" });

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 1935

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
When using bricks_create_post in a loop to create many posts, the filter index may not update for each one. Run bricks_reindex_filters once after all posts are created to ensure accurate counts.

Tips & Warnings

Tips & Warnings

Run reindex once after bulk operations, not after every individual post creation. The reindex scans all posts, so running it once at the end is more efficient.

This is a server-side operation that may take a few seconds on sites with thousands of posts. It does not affect the frontend during execution.

Return Values

FieldTypeDescription
successbooleanWhether the reindex operation completed successfully.
messagestringStatus message describing what was reindexed.

Related Tools

Technical Details

Tool ID
bricks_reindex_filters
API Endpoint
/bricks-mcp/v1/site-settings/reindex-filters
HTTP Method
POST
Namespace
content-queries
Source File
content/filters.ts
Version
1.0
Min Bricks Version
2.0
Requires Auth
Yes

Changelog

v1.0
Initial release
20250101