title: Removing 'Empty' Categories/SubCategories from a WooCommerce NavBar in WordPress
body: <p>The code below allows a user to hide 'empty' category and subcategory levels on a WooCommerce site when there are no products within a category level, but I have realised this is not the correct way to code this function as it uses the <em><strong>'product id'</strong></em> as a reference, when really it needs to be referencing and checking itself against the <em><strong>'stock levels'</strong></em> of any products that may be in said category/subcategory level instead.</p>
  <p>Is anyone able to amend the following code to check against <strong>stock levels</strong> rather than product id's? I have tried, but without success.</p>
  <pre><code>function nav_remove_empty_category_menu_item ( $items, $menu, $args ) {
      if ( ! is_admin() ) { 
          global $wpdb;
          $nopost = $wpdb-&gt;get_col( &quot;SELECT term_taxonomy_id FROM $wpdb-&gt;term_taxonomy WHERE count = 0&quot; );
          foreach ( $items as $key =&gt; $item ) {
              if ( ( 'taxonomy' == $item-&gt;type ) &amp;&amp; ( in_array( $item-&gt;object_id, $nopost ) ) ) {
                  unset( $items[$key] );
              }
          }
      }
      return $items;
  }
  
  add_filter( 'wp_get_nav_menu_items', 'nav_remove_empty_category_menu_item', 10, 3 );
  </code></pre>