×
Black Friday Savings
00Days
:
07Hours
:
49Minutes
:
27Seconds
Use Coupon 40%OFF

Includes 1 Year Priority Support

Shop Now

WP SITES

3093 Coded Tutorials & 296 Plugins

Only Show Top Level Parent Categories in WooCommerce Product Categories Widget

This code removes any sub or child categories from the WooCommerce Product categories widget.

You can add the code to the end of your child themes functions file or custom code snippets plugin.

add_filter( 'woocommerce_product_categories_widget_args', 'show_only_parent_product_categories' );
function show_only_parent_product_categories( $args ) {
    $args['parent'] = 0; // Show only top-level categories
    return $args;
}

Tested and works.

See line 294 in wp-content/plugins/woocommerce/includes/widgets/class-wc-widget-product-categories.php to learn more about this filter and the code you can modify when using it.

Was this helpful?

Yes
No
Thanks for your feedback!