Couldn’t find any working snippet in Google, so I decided to write it myself. This snippet will hide the Uncategorized category from front-end.
1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 |
function remove_uncategorized_category( $terms, $taxonomy, $query_vars, $term_query ) { if ( is_admin() ) return $terms; if ( $taxonomy[0] == 'product_cat' ) { foreach ( $terms as $k => $term ) { if ( $term->term_id == get_option( 'default_product_cat' ) ) { unset( $terms[$k] ); } } } return $terms; } add_filter( 'get_terms', 'remove_uncategorized_category', 10, 4 ); |