How to remove a certain category from Woocommerce category widget ?

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.

woocommerce

Here you can see the woocommerce category widget. Drag the widget and insert it into woocommerce side bar area.

woocommerceNow on the front end you’ll see the category widget shown in the side menu.

woocommerceNow 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.

woocommerceClick on the category to edit. Here you can see the id of this category.

woocommerceNow 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:

woocommerceNow if you go to front end and refresh the page you’ll see the specific category being removed.

woocommerce

Waqas

I hope you enjoy reading this blog post. If you want my team to do WooCommerce Maintenance for you, click here.

4 thoughts on “How to remove a certain category from Woocommerce category widget ?”

Leave a Comment

Your email address will not be published. Required fields are marked *