I'm trying to change wordpress default search behavior in order to consider taxonomies names too. If I inform on the search input the value 'Cybercops', I want the wordpress search to look for posts that have the cybercops word.
But the blog have a custom taxonomy named Heros, and one of the Heros categories could have the name 'Cybercops' too. So, If a post or custom post belongs to these 'Cybercops' Heros category, this posts has to appear on the result of the search.
So far, I have this, because I want to bring future post too:
function my_theme_my_custom_search( $query ) {
if( $query->is_main_query() && $query->is_search() && !is_admin()) {
$query->set( 'post_status', array('publish, future') );
}
}
add_action( 'pre_get_posts', 'my_theme_my_custom_search' );
I tried to use one more $query->set using tax_query but it doesn't work. Can someone help me?