1

When WooCoomerce updated to version 3.3, the 'Uncategorized' product category was added and then appeared on all pages (including the WooCommerce shop page) where products were displayed if there are any products with. All products that do not have at least one assigned category is then then (logically I guess) assigned to the 'uncategorised' category.

I always used the (possibly not ideal) approach of hiding seasonal products by removing all categories from these products when they were out of season. This new change meant that these 'hidden' products all of a sudden appeared on the site for sale in this new category which I do not want on any page.

I have searched the web looking for a way of hiding the 'Uncategorized' product category and found that this problem is widespread. A number of solutions were proposed including making the “uncategorized” category a subcategory and then hiding all the subcategories or hiding categories using CSS.

See https://wordpress.org/support/topic/uncategorized-product-category-still-showing-after-3-3-1/

However, none of these solutions are 'clean' or robust enough.

My work-around has been to only show the products that I want visible by using the product categories shortcode (without the uncategorised category id). For example:

[product_categories ids="11, 19, 18, 14, 7, 8, 9, 10, 15, 98, 16, 17"]

but this does not solve the issue on the shop page (which does not use shortcodes).

I wonder if anyone has a robust method for hiding the 'Uncategorized' product category as is an issue that is topical and appears to be widespread at the moment.

2

I solved this problem based on code kindly provided by rynoldos (https://gist.github.com/rynaldos/a9d357b1e3791afd9bea48833ff95994) as follows:

Include the following code in your functions.php file:

/** Remove categories from shop and other pages
 * in Woocommerce
 */
function wc_hide_selected_terms( $terms, $taxonomies, $args ) {
    $new_terms = array();
    if ( in_array( 'product_cat', $taxonomies ) && !is_admin() && is_shop() ) {
        foreach ( $terms as $key => $term ) {
              if ( ! in_array( $term->slug, array( 'uncategorized' ) ) ) {
                $new_terms[] = $term;
              }
        }
        $terms = $new_terms;
    }
    return $terms;
}
add_filter( 'get_terms', 'wc_hide_selected_terms', 10, 3 );

This code applies to the shop page on WooCommerce. If you would like to apply this to a different page, replace is_shop() with is_page('YOUR_PAGE_SLUG').

I too had a run-around trying to find a solution to this problem, but the above code works well for me.

1

I have found a simple way to hide Uncategorized category in the shop page: I have changed its Parent category "None" by another category I have.

Hope it helps :-)

Marianne

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service, privacy policy and cookie policy

Not the answer you're looking for? Browse other questions tagged or ask your own question.