Skip to content

Instantly share code, notes, and snippets.

@wpadmin
Last active December 3, 2021 16:01
Show Gist options
  • Save wpadmin/50fde22b9a68e5b24f42598326509589 to your computer and use it in GitHub Desktop.
Save wpadmin/50fde22b9a68e5b24f42598326509589 to your computer and use it in GitHub Desktop.
WooCommerce 3.3 - Hide uncategorized category from the shop page on the frontend and Remove Categories from WooCommerce Product Category Widget
<?php
/**
* WooCommerce 3.3 - Hide uncategorized category from the shop page on the frontend and Remove Categories from WooCommerce Product Category Widget
*/
add_filter( 'woocommerce_product_subcategories_args', 'krs_remove_uncategorized_category' );
add_filter( 'woocommerce_product_categories_widget_args', 'krs_remove_uncategorized_category' );
add_filter( 'woocommerce_product_categories_widget_dropdown_args', 'krs_remove_uncategorized_category' );
add_filter( 'ywcca_wc_product_categories_widget_args', 'krs_remove_uncategorized_category' );
function krs_remove_uncategorized_category( $args ) {
$args['exclude'] = get_option( 'default_product_cat' );
return $args;
}
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment