I wanted to share an update on my issue with Live Search in Bricks Builder. Thanks to the amazing support from the Bricks community, especially Jenn Lee, we found a solution!
The Solution:
To make Live Search work only on specific ACF fields (e.g., field_1, field_2) and avoid searching in post_title or post_content, you can use the bricks/posts/query_vars filter to unset the s= parameter and apply a Meta Query. Here’s a simplified example:
add_filter('bricks/posts/query_vars', function($query_vars, $settings, $element_id) {
if ($element_id === 'your_query_loop_id') {
$search_term = '';
if (isset($query_vars['s'])) {
$search_term = $query_vars['s'];
unset($query_vars['s']);
}
if (!empty($search_term)) {
$query_vars['meta_query'] = [
'relation' => 'OR',
[ 'key' => 'field_1', 'value' => $search_term, 'compare' => 'LIKE' ],
[ 'key' => 'field_2', 'value' => $search_term, 'compare' => 'LIKE' ],
];
} else {
$query_vars['meta_query'] = [
[ 'key' => 'field_1', 'value' => 'nonexistent_value', 'compare' => 'LIKE' ],
];
}
$query_vars['post_type'] = 'your_cpt';
}
return $query_vars;
}, 1000, 3);
Note: Disable “Query Bricks data in search results” in Bricks Settings → Miscellaneous to prevent searching in post_content.
Big thanks to Jenn and the community for the help!