inovve

Woocommerce hide specific categories from category widget

Nov 27th, 2019
233
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
PHP 0.63 KB | None | 0 0
  1. function exclude_woocommerce_widget_product_categories($widget_args) {
  2.     //Insert excluded category ids here
  3.     $excludes = array(12,33);
  4.     $includes = explode(",",$widget_args['include']);
  5.  
  6.     $includes = array_filter($includes, function($value) use ($excludes) {
  7.       return !in_array($value, $excludes);
  8.     });
  9.     $widget_args["include"] = implode(",", $includes);
  10.     return $widget_args;
  11. }
  12. add_filter( 'woocommerce_product_categories_widget_dropdown_args', 'exclude_woocommerce_widget_product_categories');
  13. add_filter( 'woocommerce_product_categories_widget_args', 'exclude_woocommerce_widget_product_categories');
Advertisement
Add Comment
Please, Sign In to add comment