In WooCommerce 3.3 we introduced a new uncategorized category all product will default to when no other category is assigned to them. This is the same behavior that WordPress uses for posts. With that, unfortunately, if your shop is set up to display categories on the shop page then this new uncategorized category will also show up.
Although we give you the possibility to rename the category to whatever you would like, there might be cases where you would like to rather not display this on your shop page. To do that you can simply add the following piece of code to your site via your theme’s functions.php file, or via a custom plugin. Remember to not include the opening tag<?php
if you are adding this to an existing file.
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 | |
add_filter( 'woocommerce_product_subcategories_args', 'remove_uncategorized_category' ); | |
/** | |
* Remove uncategorized category from shop page. | |
* | |
* @param array $args Current arguments. | |
* @return array | |
**/ | |
function remove_uncategorized_category( $args ) { | |
$uncategorized = get_option( 'default_product_cat' ); | |
$args['exclude'] = $uncategorized; | |
return $args; | |
} |