DescriptionDescription
This filter is called before the search facet queries object ids (posts, terms, users).
It allows to modifies the search query arguments made by WP_Query
, WP_Term_Query
or WP_User_Query
.
ArgumentsArguments
Argument | Type | Description |
$query | array | Holds search query args |
$facet | array | Holds facet settings |
ExampleExample
PHP
functions.php
function prefix_search_query_args( $query_args, $facet ) {
// We exclude post IDs from search if facet ID is equal to 1.
if ( 1 === $facet['id'] ) {
$query_args['post__not_in'] = [ 1, 2, 3, 4 ];
}
return $query_args;
}
add_filter( 'wp_grid_builder/facet/search_query_args', 'prefix_search_query_args', 10, 2 );