I am trying to block the visualization of a custom post, of type 'product', if it is assigned to certain values of the taxonomy 'product_cat'. Strictly speaking, I would like to block the visualization of a product if it falls under certain categories. I can not make this work, even by hardcoding a forbidden name for a product_cat ('plus' in this example). function filter($query){ if ($query->is_single && is_main_query()) { $tax_query = array( array( 'taxonomy' => 'product_cat', 'field' => 'name', 'terms' => array('plus'), 'operator' => 'NOT IN', ) ); $query->set( 'tax_query', $tax_query ); return; } } add_filter('pre_get_posts','filter'); If I try to visualize a product falling under the 'plus' category, Wordpress shows it despite this filter. What am I missing here? Cheers!