Você pode definir a consulta de taxonomia para a consulta principal usando pre_get_posts:
add_action( 'pre_get_posts', 'my_exclude_terms_from_query' );
function my_exclude_terms_from_query( $query ) {
if ( $query->is_main_query() /* && whatever else */ ) {
$tax_query = array (
array(
'taxonomy' => 'category',
'terms' => array( 'cat-slug' ),
'field' => 'slug',
'operator' => 'NOT IN',
)
);
$query->set( 'tax_query', $tax_query );
}
}
Se tax_query
já estiver definido e você precisar modificá-lo, poderá pegá-lo e adicioná-lo à matriz $tax_query
.