title: Get all Woocommerce products from current product category term Id in a WP_Query
body: <p>I have a simple taxonomy-product_cat.php page, where I am trying to display only the products in the current category. Right now, it's displaying all products, not just the ones in the current category. Here is my code:</p>
  
  <pre><code>&lt;ul class="products"&gt;
  
      &lt;?php
         $current_cat_id = $wp_query-&gt;get_queried_object()-&gt;term_id;
         $args = array(
           'taxonomy'       =&gt; 'product_cat',
           'post_type'      =&gt; 'product',
           'post_status'    =&gt; 'publish',
           'posts_per_page' =&gt; -1,
           'tax_query'      =&gt; array(
               'taxonomy'   =&gt; 'product_cat',
               'field'      =&gt; 'term_id',
               'terms'      =&gt; $current_cat_id,
               'operator'   =&gt; 'IN'
           )
         );
  
         $products = new WP_Query( $args );
  
         while ( $products-&gt;have_posts() ) : $products-&gt;the_post();
             echo '&lt;li&gt;&lt;a href="'. get_permalink() .'"&gt;&lt;div class="product__preview"&gt;&lt;img src="' . get_the_post_thumbnail_url() . '"&gt;&lt;/div&gt;&lt;span&gt;' . get_the_title() . '&lt;/span&gt;&lt;/a&gt;&lt;/li&gt;';
         endwhile;
  
         wp_reset_query();
         ?&gt;
  &lt;/ul&gt;
  </code></pre>
  
  <p>My client keeps changing the names/slugs of the category, so I need to get the products by category ID. Any idea why this is generating all products, instead of just the ones in the current category?</p>