You can hide certain WooCommerce product categories from the shop page or other targetted pages, by using an action called woocommerce_product_query

Add it in your theme via functions.php and it works like so…

So the action is wrapped in a conditional statement that targets the pages you want the Product Categories to not display.

Then in the $tax_query array set the terms value array to the actual Product Categories you need to be removed.



  1. Marcel Kraan on October 20, 2020 at 4:13 pm

    And YES you are the best!!!!
    Thank you this works as a Rolls Royce
    Now i try to make my own plugin with options in Woocommerce settings!

    • Marcel Kraan on October 20, 2020 at 4:30 pm

      I have changed a condition and it seems that it works
      I only changed this line

      // if( is_shop() || is_page(‘awards’) ) { // set conditions here
      if ( is_page(‘Home’) ) { // set conditions here

  2. guy man dude on August 29, 2020 at 9:23 pm

    Finally – the right solution. Thanks.

  3. Titus on August 21, 2020 at 7:29 am

    Thank you, saved me quite a bit of time.

  4. WPseason on August 9, 2020 at 4:27 pm

    How Can I hide product in Woocommerce but still available when user has the URL of the page?
    I just want to hide it from the list in shop and category page.

  5. aaron davis on April 30, 2020 at 1:47 pm

    This helped me so much, easy to setup and do for people with only a little bit of coding knowledge.

  6. nic on October 31, 2019 at 2:12 pm

    does not work!

  7. Mark Simkiss on May 24, 2019 at 4:08 pm

    There is hope! Trying to figure out something that seems easy but I don’t have the expertise. Perhaps it would be easy for you? What I need to do is exclude products in specific categories (or with specific tags) from appearing on the main shop page. I want them show up on the category URL: as they are all categorized with “clientname”. Works great. However, they also show up on the main shop page “” from which I would like to hide them. I only want them to show up if you go to the category URL. How would that be done? (also, all without a password/login)

  8. +ES on April 15, 2019 at 7:40 pm


    Thank you very much for posting this information and code! I am very interested in using this, but I have about 50 categories for my bakery shop and I only want to show 1 category on the Shop Page. Is there a way to say “include this 1 category only” instead of “exclude these 49 categories” via code…

    Right now I would have to add all 49 categories and as I make new categories (for new baked goods) I would need to add each of those to the code-list. But, if the code said show one category that would be an easier way for me as I will always want to show only that one category on the Shop page (no matter how many new ones I create).

    I can provide additional information, if you need it. Thank you for your guidance and time on this!

  9. Jonathan on June 13, 2018 at 4:38 am

    Hello. This is great and I really appreciate you sharing.

    One question: I’d like to exclude categories on the ‘products’ page and any subpage of ‘products’, for example ‘products/page/2/’

    Is there a way in the code to target the main page and all child pages?

  10. Luc on April 20, 2018 at 2:22 pm

    How instead of page name “award” can I use the page id?

    • Neil Gowran on April 20, 2018 at 8:55 pm

      Put id number in the parentheses

  11. David Dunnington on April 19, 2018 at 11:50 am

    Was looking for this for quite a while. Worked perfectly thank you.

  12. siyad on February 9, 2018 at 12:57 pm

    its working thanx

  13. Micki on November 23, 2017 at 1:15 am

    Hi, this is not working, though I was excited to find it!

    I replaced:
    if( is_shop() || is_page(‘awards’) ) with is_page(‘my-shop-page’) )

    And replaced/added my category slugs here:
    ‘terms’ => array( ‘cat1’, ‘cat2’ )

    will it only work with new categories created after adding the snippet? thanks!

Leave a Comment