/facet/search_query_args

DescriptionDescription

This filter is called before the search facet query object ids (posts, terms, users).

It allows to modifies the search query arguments made by WP_QueryWP_Term_Query or WP_User_Query.

ArgumentsArguments

ArgumentTypeDescription
$query array Holds search query args
$facetarrayHolds 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 );