Hide the "Uncategorized" Product Category
Keeps the default Uncategorized product category out of category lists on the shop and in the product categories block and widget.
Opens WPIDE on
Code
add_filter( 'get_terms_args', function ( $args, $taxonomies ) {
if ( is_admin() || ! in_array( 'product_cat', (array) $taxonomies, true ) ) {
return $args;
}
$default = (int) get_option( 'default_product_cat' );
if ( $default ) {
$args['exclude'] = array_merge( wp_parse_id_list( $args['exclude'] ?? array() ), array( $default ) );
}
return $args;
}, 10, 2 );
Notes
Products in the category are still visible in the shop; only the category itself is hidden.
How to add this snippet
- Install WPIDE on your WordPress site (it is free) and open Code Snippets.
- Use snippet above adds it from the library in one click. Or copy the code into a new snippet with the same code type.
- It is added inactive: review the code and settings, then switch it on.