Hide products from shop page but not entire shop
-
Hi there,
I’m looking for a way to hide products of a specific category (mut-haves) on the shop page. I don ‘t want to hide them in my entire shop, only on the front page of my shop.
I made an simple image of what I want.
https://cloud.perrymedia.nl/index.php/s/Vku3UREhU0jfcaZ
password ‘perrymedia’This option will hide the products in my entire shop, even when you select the category.
/** * Exclude products from a particular category on the shop page */ function custom_pre_get_posts_query( $q ) { $tax_query = (array) $q->get( 'tax_query' ); $tax_query[] = array( 'taxonomy' => 'product_cat', 'field' => 'slug', 'terms' => array( 'musthaves' ), // Don't display products with category "musthave" on the shop. 'operator' => 'NOT IN' ); $q->set( 'tax_query', $tax_query ); } add_action( 'woocommerce_product_query', 'custom_pre_get_posts_query' );
The page I need help with: [log in to see the link]
Viewing 4 replies - 1 through 4 (of 4 total)
Viewing 4 replies - 1 through 4 (of 4 total)
- The topic ‘Hide products from shop page but not entire shop’ is closed to new replies.