Skip to content

Instantly share code, notes, and snippets.

@croosen
Last active August 29, 2015 14:06
Show Gist options
  • Save croosen/83ce8a3bc8ee520eb7ba to your computer and use it in GitHub Desktop.
Save croosen/83ce8a3bc8ee520eb7ba to your computer and use it in GitHub Desktop.
WooCommerce - Show all subcategories in product category / archive pages - even when empty
$args = apply_filters( 'woocommerce_product_subcategories_args', array(
'parent' => $parent_id,
'menu_order' => 'ASC',
'hide_empty' => 0,
'hierarchical' => 1,
'taxonomy' => 'product_cat',
'pad_counts' => 1
) );
// Update: Use this in your functions.php:
add_filter('woocommerce_product_subcategories_args', 'woocommerce_show_empty_categories');
function woocommerce_show_empty_categories($args){
$args['hide_empty']=0;
return $args;
}
@croosen
Copy link
Author

croosen commented Sep 22, 2014

By default, "hide_empty" was set to 1, preventing empty sub/child categories to be displayed. I needed a fully click through catalog (click from parent to > sub > sub > sub even when empty) and therefore had to set this setting to 0. Not best practice to do this in core files, may want to find a better way to override it.

@croosen
Copy link
Author

croosen commented Sep 22, 2014

D'oh! :-) Just use this in your funcions.php:

add_filter('woocommerce_product_subcategories_args', 'woocommerce_show_empty_categories');
function woocommerce_show_empty_categories($args){
$args['hide_empty']=0;
return $args;
}

@alemarengo
Copy link

Hi!
Is it possible to HIDE a specific category or subcategory from the whole shop using woocommerce_product_subcategories_args?

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment