title: How can I get product count in each category like WooCommerce back-end?
body: <p>I am building a new site and I am pretty comfortable with Woocommerce. I just need a quick trick to get the product count in each category. I'm already calling out the category on each product but cannot figure out how to get the product count from that category.</p>
  
  <p>I have a list style going for my products(really activities for an activity site). <a href="https://dl.dropboxusercontent.com/u/13502930/mac.png" rel="nofollow">Check out image</a>.</p>
  
  <p>I just want to echo out the count of "activities" next to the category. This is how I am getting my category:        </p>
  
  <pre><code>echo $product-&gt;get_categories( ', ', '&lt;span class="posted_in"&gt;' . _n( 'Category:', 'Categories:', sizeof( get_the_terms( $post-&gt;ID, 'product_cat' ) ), 'woocommerce' ) . ' ', '.&lt;/span&gt;' );
  </code></pre>
  
  <p>I tried to get the count by using: </p>
  
  <pre><code>$numposts = $wpdb-&gt;get_var("SELECT COUNT(*) FROM $wpdb-&gt;posts WHERE post_status = 'publish'");
  echo $numposts;
  </code></pre>
  
  <p>But it is echoing out some weird number. I tried a few variations of that query, calling out for product and such.</p>
  
  <p><strong>[update]</strong>  </p>
  
  <p>This is what I was able to do: </p>
  
  <pre><code>&lt;li&gt;&lt;?php 
  $cat1 = $product-&gt;get_categories( ', ', '&lt;span class="posted_in"&gt;' . _n(     'Category:', 'Categories:', sizeof( get_the_terms( $post-&gt;ID, 'product_cat' ) ),  'woocommerce' ) . ' ', '.&lt;/span&gt;' ); 
  echo $cat1;
  /* 
  $args = array( 'taxonomy' =&gt;  'product_cat' ); 
  $terms = get_terms('product_cat', $args); 
  echo count($terms);
  */ 
  $args = array( 'post_type' =&gt; 'product',  'taxonomy' =&gt; $cat1[0] ); 
  $loop = new WP_Query( $args );
  while ( $loop-&gt;have_posts() ) : $loop-&gt;the_post(); 
      echo count( $loop-&gt;post-&gt;ID ) 
  endwhile; 
  wp_reset_query(); // Remember to reset 
  ?&gt;&lt;/li&gt;
  </code></pre>
  
  <p>But it actually counts out all the products in all categories by increments of "1".... So instead of echoing "category: abc has "3" product" it's echoing "category: abc has "1 1 1 1 1 1 1"</p>
  
  <p>I know there is a simple filter that I can do here, I feel like I am right there.</p>