In this tutorial we’ll learn how to skip/remove a particular category from the woocommerce menu widget.
First of all add the woocommerce category widget to sidebar/footer where ever you want. To add the widget in any of the area login to backend and go to widget area.
Here you can see the woocommerce category widget. Drag the widget and insert it into woocommerce side bar area.
Now on the front end you’ll see the category widget shown in the side menu.
Now we want to remove a specific category from this. Lets say we want to remove category 1-1-1 from the widget. To do this go to backend and navigate to categories section under products.
Click on the category to edit. Here you can see the id of this category.
Now add the following lines of code at the end of your functions.php file.
add_filter( 'woocommerce_product_categories_widget_args', 'woo_product_cat_widget_args' ); function woo_product_cat_widget_args( $cat_args ) { $cat_args['exclude'] = array('15'); return $cat_args; }
Don’t forget to replace the id of your category with the value in array.
You can access functions.php here:
Now if you go to front end and refresh the page you’ll see the specific category being removed.
That’s ok, thanks you very much
Thank you, it works and it’s simple.
4.5 years later and this code still works perfectly with the latest version of Woo. Thank you!
Still works in 2020 with the latest version of Woo. Thank you!