On a specific page, I would like the search to be performed only against the terms from two custom taxonomies. Not the content or title. That is, the user is directly searching taxonomy terms.
What I'm trying to do is completely rewrite the query for searches, but it doesn't seem to work.
function search_filter_get_posts($query) {
if ( !$query->is_search )
return $query;
$terms = explode(",", $query->query['s']);
$taxquery = array(
'post_type' => 'eproduct',
'tax_query' => array(
'relation' => 'OR',
array(
'taxonomy' => 'product-type',
'field' => 'slug',
'terms' => $terms,
),
array(
'taxonomy' => 'product-features',
'field' => 'slug',
'terms' => $terms,
),
),
);
;
$query = new WP_Query( $taxquery );
}
add_action( 'pre_get_posts', 'search_filter_get_posts' );