skip to Main Content

I tried code below to hide a Uncategorized category, but in others languages this category is visible, how to fix it

function my_product_subcategories_arg( $args ) {
    $uncategorized = get_option( 'default_product_cat' );
    $args['exclude'] = $uncategorized;
    $args['hide_empty'] = 0;
    return $args;
}
add_filter( 'woocommerce_product_subcategories_args', 'my_product_subcategories_arg', 10, 1 );

2

Answers


  1. Chosen as BEST ANSWER

    This helped me:

    add_filter('woocommerce_product_categories_widget_args', 'exclude_category');
    function exclude_category($args) {
    $args['exclude'] = array('15');
            return $args;
    }
    

  2. So for all other categories it works? If yes then pick a different category that you don’t need to hide and make it default:

    • In wp-admin go to Settings > Writing
    • Find Default Post Category drop-down and select any other category other than Uncategorized, save changes.
    Login or Signup to reply.
Please signup or login to give your own answer.
Back To Top
Search