Last active
May 25, 2020 15:12
-
-
Save renventura/8c84e03329ba1c06a10c to your computer and use it in GitHub Desktop.
Removes an array of product categories from the WooCommerce Product Category Widget.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
<?php // Mind this opening php tag | |
/** | |
* Remove Categories from WooCommerce Product Category Widget | |
* | |
* @author Ren Ventura | |
*/ | |
//* Used when the widget is displayed as a dropdown | |
add_filter( 'woocommerce_product_categories_widget_dropdown_args', 'rv_exclude_wc_widget_categories' ); | |
//* Used when the widget is displayed as a list | |
add_filter( 'woocommerce_product_categories_widget_args', 'rv_exclude_wc_widget_categories' ); | |
function rv_exclude_wc_widget_categories( $cat_args ) { | |
$cat_args['exclude'] = array('55','68'); // Insert the product category IDs you wish to exclude | |
return $cat_args; | |
} |
The code only seems to work for the shop page, and not the category pages. Tested With WooCommerce Version: 3.6.5
@princebhalani143 It seems to be working for me just fine, including on the category pages (also running WC 3.6.5). Can you provide steps for reproducing this?
@renventura: Thanks for looking into this, I've tried on local host with basic WooCommerce + WordPress + Default theme and it's working smoothly. It's conflict from the Salient theme widget plugin.
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
This filter perfectly works .... Thanks Man :) 👍