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.