title: WooCommerce custom ShortCodes
body: <p>I am trying to create a custom shortcode for WooCommerce, I want to display featured products from a specific catagory at the end of a post.</p>
  
  <p>There is a standard shortcode:</p>
  
  <pre><code>[featured_products per_page="12" columns="4" orderby="date" order="desc"]
  </code></pre>
  
  <p>I want to add catagory to this, so the new shortcode will be:</p>
  
  <pre><code>[featured_category_products category="13" per_page="4" columns="4" orderby="date" order="desc"]
  </code></pre>
  
  <p>To get it work it's officiously necessary to  create a function for it, so I found the class-wc-shortcodes.php file with all the default shortcodes.</p>
  
  <p>I add a new function based on the default featured product:</p>
  
  <pre><code>public function featured_category_products( $atts ) {
  
      global $woocommerce_loop;
  
      extract(shortcode_atts(array(
          'category'      =&gt; '',
          'per_page'  =&gt; '4',
          'columns'   =&gt; '4',
          'orderby' =&gt; 'date',
          'order' =&gt; 'desc'
      ), $atts));
  
      $args = array(
          'post_type' =&gt; 'product',
          'post_status' =&gt; 'publish',
          'ignore_sticky_posts'   =&gt; 1,
          'posts_per_page' =&gt; $per_page,
          'orderby' =&gt; $orderby,
          'order' =&gt; $order,
          'meta_query' =&gt; array(
              array(
                  'key' =&gt; '_visibility',
                  'value' =&gt; array('catalog', 'visible'),
                  'compare' =&gt; 'IN'
              ),
              array(
                  'key' =&gt; '_featured',
                  'value' =&gt; 'yes'
              )
          ),
          'tax_query'             =&gt; array(
              array(
                  'taxonomy'      =&gt; 'product_cat',
                  'terms'         =&gt; array( esc_attr($category) ),
                  'field'         =&gt; 'slug',
                  'operator'      =&gt; 'IN'
              )
          )
      );
  
      ob_start();
  
      $products = new WP_Query( $args );
  
      $woocommerce_loop['columns'] = $columns;
  
      if ( $products-&gt;have_posts() ) : ?&gt;     
  
          &lt;?php woocommerce_product_loop_start(); ?&gt;
  
              &lt;?php while ( $products-&gt;have_posts() ) : $products-&gt;the_post(); ?&gt;
  
                  &lt;?php woocommerce_get_template_part( 'content', 'product' ); ?&gt;
  
              &lt;?php endwhile; // end of the loop. ?&gt;
  
          &lt;?php woocommerce_product_loop_end(); ?&gt;
  
      &lt;?php endif;
  
      wp_reset_postdata();
  
      return '&lt;div class="woocommerce"&gt;' . ob_get_clean() . '&lt;/div&gt;';
  }
  </code></pre>
  
  <p>I added the category variable extraction (and checked if it worked) and added tax-query part (found it from another function that show product based on categories). So I thought this should work, but off course not. I don't get any results nor a error.</p>
  
  <p>Anybody an idea how the get this to work? </p>