Exclude Categories From The WooCommerce Product Category Widget

Add this code to the end of your child themes functions.php file to exclude one of more product categories from displaying in the WooCoomerce Product Category widget.


The above code removes 2 categories.

Simply change the category i.d’s to suit your own needs.


Comments

7 responses to “Exclude Categories From The WooCommerce Product Category Widget”

  1. Hi Brad

    Found this through your answer on stackoverflow. Thanks for providing the snippet however I cannot get it to work. My category stays in the “woocommerce product categories widget”. I of course changed the category id. Could it be a change in Woo 2.2? I looked at the class-wc-widget-product-categories.php but couldn’t see any change. This file however is not in the new Woo 2.2 widget-product_categories.php

    Appreciate any help you can provide.

    Thanks
    Wendy

  2. Fernando Avatar
    Fernando

    Is possible to affect two sidebars? For example in sidebar 1 I have the widget and want to exclude 3 of 10 categories in sidebar 2 I have the same widget but I want to exclude only 1 category.

    1. Brad Dalton Avatar
      Brad Dalton

      You can modify the code to do that.

      1. Fernando Avatar
        Fernando

        Do you have any example for that?

        1. Brad Dalton Avatar
          Brad Dalton

          The code would need to be written and tested.

  3. Jason Avatar

    Is there a way to do this for woocommerce shortcode? ie [product_categories number="12" parent="0"]

    1. Brad Dalton Avatar
      Brad Dalton

      You could add a argument to the code to do this.

Leave a Reply

Join 5000+ Followers

Get The Latest Free & Premium Tutorials Delivered The Second They’re Published.