How to hide a specific product from shop page but still show elsewhere
-
Hello, noobie here. I do subscription boxes reviews, so my main Shop Page features only affiliate links so people can subscribe to my favorite boxes. I do not sell anything EXCEPT a custom mystery box with items I receive double or do not want. I want THAT sole item to be offered at the Main Menu (top menu) under a “Shop Mystery Bag” link. That link I have as a product category and currently is called “Tienda”.
But, that item is appearing at the main shop page (where the affiliate links are). How to hide it from there and only show it at its link?
Ive found the following code which I have NO IDEA where to put it or if I should put it or even what it does, but I searched first on the forum and found a question very similar to mine. This was the solution. Do you think its a good solution for me? If so, what do I do with it?
add_action( ‘woocommerce_product_query’, ‘prefix_custom_pre_get_posts_query’ ); /** * Hide Product Cateories from targetted pages in WooCommerce * @link https://gist.github.com/stuartduff/bd149e81d80291a16d4d3968e68eb9f8#file-wc-exclude-product-category-from-shop-page-php * */ function prefix_custom_pre_get_posts_query( $q ) { if( is_shop() || is_page(‘shop’) ) { // set conditions here $tax_query = (array) $q->get( ‘tax_query’ ); $tax_query[] = array( ‘taxonomy’ => ‘product_cat’, ‘field’ => ‘slug’, ‘terms’ => array( ‘musthave’ ), // set product categories here ‘operator’ => ‘NOT IN’ ); $q->set( ‘tax_query’, $tax_query ); } }
Here is the main Shop Page and the item that I DONT want there is the purple one named “Mika Bunch”: https://146.66.97.212/~micajita/shop/
I want that item here: https://146.66.97.212/~micajita/product-category/prods/
It appears where I want it to, but I dont want it to appear on main shop page.Any idea?
Thanks!
-Christina Mika
- This topic was modified 6 years, 2 months ago by .
- This topic was modified 6 years, 2 months ago by .
The page I need help with: [log in to see the link]
- The topic ‘How to hide a specific product from shop page but still show elsewhere’ is closed to new replies.