Viewing 8 posts - 1 through 8 (of 8 total)
  • Author
    Posts
  • #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’ );

    }

    #804888

    Hey 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 Torvik

    #1034159

    Hi! 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!

    #1034215

    Hey AleFalkinhoff,

    Please provide a link to your site, as well as the category you want to hide.

    Best regards,
    Jordan Shannon

    #1034227
    This reply has been marked as private.
    #1034556

    Hi,

    Add this to quick css:

    .product-category.product.first{
    display:none!important;
    }

    Best regards,
    Jordan Shannon

    #1034632
    This reply has been marked as private.
    #1034860

    Hi,

    Apologies, you can try this method:

    https://www.tychesoftwares.com/hide-woocommerce-categories-shop/

    Best regards,
    Jordan Shannon

Viewing 8 posts - 1 through 8 (of 8 total)
  • You must be logged in to reply to this topic.