Hide product categories if empty by leaving them positioned in the same place in the menu

I think with your question to hide the empty product categories in menu, we can add extra class for this menu item then adding CSS to hide these specific items.

  1. This code will add extra class hidden to empty product categories
add_filter('nav_menu_css_class', function($classes, $menu_item, $args, $depth){
    if('taxonomy' == $menu_item->type){
        $term_id = $menu_item->object_id;
        $term    = get_term($term_id, $menu_item->object);
        if(!is_wp_error($term)){
            if($term->count <= 0){
                $classes [] = 'hidden';
            }
        }
    }
    return $classes;
}, 10, 4);
  1. Then adding new CSS to hide these items
    .hidden {display:none;}

deneme bonusu veren sitelerbahis casinomakrobetceltabetpinbahispolobetpolobet girişpinbahis girişmakrobet girişpulibet girişmobilbahis girişkolaybet giriş