Hello!
I used this script in functions.php to hide the category “produto-de-limpeza” this category only appeared on a separate page. So far so good, it worked perfectly.
*************************************************
This is the code used.
add_action( ‘woocommerce_product_query’, ‘prefix_custom_pre_get_posts_query’ );
function prefix_custom_pre_get_posts_query( $q ) {
if( is_shop() || is_page(‘awards’) ) {
$tax_query = (array) $q->get( ‘tax_query’ );
$tax_query[] = array(
‘taxonomy’ => ‘product_cat’,
‘field’ => ‘slug’,
‘terms’ => array( ‘produto-de-limpeza’ ),
‘operator’ => ‘NOT IN’
);
$q->set( ‘tax_query’, $tax_query );
}
}
***********************************************************************
BUT when I do a product search when I click View all results it appears that no products were found.
I would like to know if there is any way to just remove the category from the shop page but still keep working when clicked on View all results in searching for products