title: Woocommerce get products
body: <p>I used the following code to get the list of product categories form WooCommerce in my WordPress website:</p>
  
  <pre><code> &lt;?php
    $taxonomy     = 'product_cat';
    $orderby      = 'name';  
    $show_count   = 0;      // 1 for yes, 0 for no
    $pad_counts   = 0;      // 1 for yes, 0 for no
    $hierarchical = 0;      // 1 for yes, 0 for no  
    $title        = '';  
    $empty        = 0;
  $args = array(
    'taxonomy'     =&gt; $taxonomy,
    'orderby'      =&gt; $orderby,
    'show_count'   =&gt; $show_count,
    'pad_counts'   =&gt; $pad_counts,
    'hierarchical' =&gt; $hierarchical,
    'title_li'     =&gt; $title,
    'hide_empty'   =&gt; $empty
  );
  ?&gt;
  &lt;?php $all_categories = get_categories( $args );
  
  //print_r($all_categories);
  foreach ($all_categories as $cat) {
      //print_r($cat);
      if($cat-&gt;category_parent == 0) {
          $category_id = $cat-&gt;term_id;
  
  ?&gt;     
  
  &lt;?php       
  
          echo '&lt;br /&gt;&lt;a href="'. get_term_link($cat-&gt;slug, 'product_cat') .'"&gt;'. $cat-&gt;name .'&lt;/a&gt;'; ?&gt;
  
  
          &lt;?php
          $args2 = array(
            'taxonomy'     =&gt; $taxonomy,
            'child_of'     =&gt; 0,
            'parent'       =&gt; $category_id,
            'orderby'      =&gt; $orderby,
            'show_count'   =&gt; $show_count,
            'pad_counts'   =&gt; $pad_counts,
            'hierarchical' =&gt; $hierarchical,
            'title_li'     =&gt; $title,
            'hide_empty'   =&gt; $empty
          );
          $sub_cats = get_categories( $args2 );
          if($sub_cats) {
              foreach($sub_cats as $sub_category) {
                  echo  $sub_category-&gt;name ;
              }
  
          } ?&gt;
  
  
  
      &lt;?php }     
  }
  ?&gt;
  </code></pre>
  
  <p>This works fine and returns the list of product categories. I have been trying now to get a list of products for a particular category.</p>
  
  <p><strong>Example</strong>: get all the products for with <code>cat_id=34</code>.</p>
  
  <p>I know products are stored as posts, and have been trying to get this done but can't seem to.</p>
  
  <p>How do I get the list of products for a particular category?</p>