-
AuthorPosts
-
June 6, 2017 at 10:07 pm #804713
I am trying to exclude a specific category from my shop overview page. I found the code below which appeared to work for others but does not work on my site. Is there something missing from the code or something I am overlooking?
I tried inserting it into my functions.php file. 9869 is the category ID I am trying to hide.
/**
* This code should be added to functions.php of your theme
**/
add_filter( ‘pre_get_posts’, ‘custom_pre_get_posts_query’ );function custom_pre_get_posts_query( $q ) {
if ( ! $q->is_main_query() ) return;
if ( ! $q->is_post_type_archive() ) return;$q->set( ‘tax_query’, array(array(
‘taxonomy’ => ‘product_cat’,
‘field’ => ‘id’,
‘terms’ => array( 9869 ),
‘operator’ => ‘NOT IN’
)));remove_filter( ‘pre_get_posts’, ‘custom_pre_get_posts_query’ );
}
June 7, 2017 at 7:54 am #804888Hey web6s,
Thanks for using our theme :)
This article ought help you: https://docs.woocommerce.com/document/exclude-a-category-from-the-shop-page/
Best regards,
John TorvikNovember 15, 2018 at 9:51 pm #1034159Hi! I have the same issue. I want to exclude or hide one specific category in my shop page. This article explain how to exclude products from a specific category, but I want to hide thumbnail and category name
Thanks!
November 16, 2018 at 1:39 am #1034215Hey AleFalkinhoff,
Please provide a link to your site, as well as the category you want to hide.
Best regards,
Jordan ShannonNovember 16, 2018 at 2:26 am #1034227This reply has been marked as private.November 16, 2018 at 7:28 pm #1034556Hi,
Add this to quick css:
.product-category.product.first{ display:none!important; }Best regards,
Jordan ShannonNovember 17, 2018 at 12:33 am #1034632This reply has been marked as private.November 18, 2018 at 4:47 pm #1034860Hi,
Apologies, you can try this method:
https://www.tychesoftwares.com/hide-woocommerce-categories-shop/
Best regards,
Jordan Shannon -
AuthorPosts
- You must be logged in to reply to this topic.
