This seems like it should be straightforward, but I'm stuck on it!
If a user searches for 'alice', I would like to show them all posts with the custom taxonomy terms of 'bob' and 'carol', regardless of if those posts contain the string 'alice' in them or not.
I'm able to set the query's tax_query so that it only shows posts with 'bob' and 'carol' as terms, but I can't reset the actual search query so that it is showing all posts, not just posts with 'alice' in them.
This is the filter I'm using to change the tax_query:
if ( !$query->is_search )
return $query;
$taxquery = array(
'relation' => 'OR',
array(
'taxonomy' => 'people',
'field' => 'slug',
'terms' => array( 'bob' ),
),
array(
'taxonomy' => 'people',
'field' => 'slug',
'terms' => array( 'carol' ),
)
);
$query->set( 'tax_query', $taxquery );
return $query;
but using this to set the search query doesn't work:
$queryvars = array(
's' => ''
);
$query->set( 'query_vars', $queryvars );