title: Woo-Commerce Product Query with Multiple Arguments
body: <p>I am trying to Query Woo-Commerce products based on the following </p>
  
  <p>Featured 
  Popular
  Promotional
  Free</p>
  
  <p>I was working to show them in isotop so I have to get all products and give specifiq tag based on my query to make filter. I was confused if I can make 4 Query as I have 4 different arguments / parameter. </p>
  
  <p>I made 4 different query and got result in 4 different array. But there have problems.</p>
  
  <ol>
  <li>I had done 4 Queries and Save result on 4 array. So there same products containing. I have to filter all products and if same product in more than one category I have to input tag like features free . as Isotop works.</li>
  <li>If I unique marge array it will not show products in multiple category. But same products can be in two categories or can be in all categories so it should add tag in duplicate product and clear duplicate products list so that in result there will be unique product with multi tag.</li>
  </ol>
  
  <p>Any idea how to do that ?</p>
  
  <p>Below is my code which providing all products.</p>
  
  <pre><code>&lt;?php
  
                                  foreach ($filter_attr as $item) {
                                      if ($item == 'featured') {
                                          $meta_query = WC()-&gt;query-&gt;get_meta_query();
                                          $tax_query = WC()-&gt;query-&gt;get_tax_query();
                                          $tax_query[] = array(
                                              'taxonomy' =&gt; 'product_visibility',
                                              'field' =&gt; 'name',
                                              'terms' =&gt; 'featured',
                                              'operator' =&gt; 'IN',
                                          );
  
                                          $query_args = array(
                                              'post_type' =&gt; 'product',
                                              'post_status' =&gt; 'publish',
                                              'ignore_sticky_posts' =&gt; 1,
                                              'posts_per_page' =&gt; '12',
                                              'orderby' =&gt; 'date',
                                              'order' =&gt; 'desc',
                                              'meta_query' =&gt; $meta_query,
                                              'tax_query' =&gt; $tax_query,
                                          );
  
  
                                          $loop = new WP_Query($query_args);
  
                                          if ($loop-&gt;have_posts()) {
                                              while ($loop-&gt;have_posts()) : $loop-&gt;the_post();
  
                                                  $featured_product = array(
                                                  "type"=&gt;$item,
                                                  "product" =&gt; get_the_ID(),
                                                  );
  
                                             endwhile;
                                          }  else {
                                              echo __('No products found');
                                          }
                                          wp_reset_postdata();
  
                                      }  elseif($item == 'popular'){
  
                                          $query_args = array(
                                              'post_type'           =&gt; 'product',
                                              'post_status'         =&gt; 'publish',
                                              'ignore_sticky_posts' =&gt; 1,
                                              'posts_per_page'      =&gt; '12',
                                              'meta_key'            =&gt; 'total_sales',
                                              'orderby'             =&gt; 'meta_value_num'
                                          );
  
                                          $loop = new WP_Query($query_args);
  
                                          if ($loop-&gt;have_posts()) {
  
                                              while ($loop-&gt;have_posts()) : $loop-&gt;the_post();
  
                                                  $id=array();
  
                                                  $popular_product = array(
                                                      "type"=&gt;$item,
                                                      "product" =&gt; get_the_ID(),
                                                  );
  
                                                  print_r($popular_product);
  
                                              endwhile;
                                          }  else {
                                              echo __('No products found');
                                          }
                                          wp_reset_postdata();
  
                                      } elseif($item == 'promotional'){
  
                                          $query_args = array(
                                              'posts_per_page' =&gt; 12,
                                              'post_type' =&gt; 'product',
                                              'meta_key' =&gt; '_sale_price',
                                              'meta_value' =&gt; '0',
                                              'meta_compare' =&gt; '&gt;='
                                          );
  
                                          $loop = new WP_Query($query_args);
  
                                          if ($loop-&gt;have_posts()) {
  
                                              while ($loop-&gt;have_posts()) : $loop-&gt;the_post();
  
                                                  $id=array();
  
                                                  $promotional_product = array(
                                                      "type"=&gt;$item,
                                                      "product" =&gt; get_the_ID(),
                                                  );
  
                                                 print_r($promotional_product);
  
                                              endwhile;
                                          }  else {
                                              echo __('No products found');
                                          }
                                          wp_reset_postdata();
                                      } elseif($item == 'freebies'){
  
                                          $query_args = array(
                                              'posts_per_page' =&gt; 12,
                                              'post_type' =&gt; array('product', 'product_variation'),
                                              'meta_query' =&gt; array(
                                                  array(
                                                      'key' =&gt; '_price',
                                                      'value' =&gt; 0,
                                                      'compare' =&gt; '&lt;=',
                                                      'type' =&gt; 'NUMERIC'
                                                  )
                                              )
                                          );
  
  
                                          $loop = new WP_Query($query_args);
  
                                          if ($loop-&gt;have_posts()) {
  
                                              while ($loop-&gt;have_posts()) : $loop-&gt;the_post();
  
                                                  $id=array();
  
                                                  $freebies_product = array(
                                                      "type"=&gt;$item,
                                                      "product" =&gt; get_the_ID(),
                                                  );
  
                                                  print_r($freebies_product);
  
                                              endwhile;
                                          }  else {
                                              echo __('No products found');
                                          }
                                          wp_reset_postdata();
                                      }
                                  }
  
                                  ?&gt;
  </code></pre>