title: I need to add custom query and add to cart button dynamic code in woocommerce?
body: <p>I was make custom template for my WordPress site. So I need to show my product in my custom template dynamically. How can i do that?</p>
  
  <p>This is my html code--> </p>
  
  <pre><code>             &lt;div class="all_content_shop"&gt;
                  &lt;div class="col-md-3 single_all_c_s"&gt; 
                      &lt;div class="shop_product_inner"&gt; 
                          &lt;a href="&lt;?php echo get_permalink( $loop-&gt;post-&gt;ID ) ?&gt;"&gt;
                              &lt;img src="http://jetsetbabies.com/wp-content/uploads/2006/07/100Juice_Organic_Apple_MAIN_v2.jpg" alt="Prduct Image" /&gt;
                              &lt;div class="shop_product_inner_caption"&gt; 
                                  &lt;h2&gt;Product Title&lt;/h2&gt;
                                  &lt;p&gt;$200&lt;/p&gt;
                                  &lt;a href=""&gt;Add to Cart&lt;/a&gt;
                              &lt;/div&gt;
                          &lt;/a&gt;
                      &lt;/div&gt;
                  &lt;/div&gt;
              &lt;/div&gt;
  </code></pre>
  
  <p>================================================</p>
  
  <p>Also i was make simple query but i did not found add to cart button dynamic code???</p>
  
  <p>This is my query code----></p>
  
  <pre><code>                &lt;div class="all_content_shop"&gt;
  
                      &lt;?php $new_posts = new WP_Query(array(
                      'post_type' =&gt; 'product', //post of page of my post type
                      'cat' =&gt; 0, // category id, 0 for all categories. 
                      'posts_per_page' =&gt; 12, 
                      'offset' =&gt; 0, //how many posts you want to eliminate from the query
                      'orderby' =&gt; '', // order by title or date ?
                      'order' =&gt; 'DESC') // order as ASC or DESC
                      ); ?&gt;
                      &lt;?php if ($new_posts-&gt;have_posts()) :
                          while ($new_posts-&gt;have_posts()) :
                                  $new_posts-&gt;the_post(); ?&gt;
  
                          &lt;div class="col-md-3 single_all_c_s"&gt; 
                              &lt;div class="shop_product_inner"&gt; 
                                  &lt;a href="&lt;?php echo get_permalink( $loop-&gt;post-&gt;ID ) ?&gt;"&gt;
                                      &lt;?php if (has_post_thumbnail( $loop-&gt;post-&gt;ID )) echo get_the_post_thumbnail($loop-&gt;post-&gt;ID, 'shop_single'); else echo '&lt;img src="'.woocommerce_placeholder_img_src().'" alt="Placeholder" /&gt;'; ?&gt;
                                      &lt;div class="shop_product_inner_caption"&gt; 
                                          &lt;h2&gt;&lt;?php the_title(); ?&gt;&lt;/h2&gt;
                                          &lt;p&gt;&lt;?php if ( ! defined( 'ABSPATH' ) ) exit; global $post, $product; ?&gt; &lt;?php echo $product-&gt;get_price_html(); ?&gt;&lt;/p&gt;
                                          &lt;a href=""&gt;Add to Cart&lt;/a&gt;
                                      &lt;/div&gt;
                                  &lt;/a&gt;
                              &lt;/div&gt;
                          &lt;/div&gt;
  
                      &lt;?php endwhile;//Possibility to add else statement ?&gt;
                          &lt;?php wp_reset_postdata(); ?&gt;
                          &lt;?php else:?&gt;
                          &lt;p class="not_found"&gt;Sorry, The post you are looking is unavailable!&lt;/p&gt;
                      &lt;?php endif; wp_reset_query(); ?&gt;
              &lt;/div&gt;
  </code></pre>
  
  <p>So my question is---></p>
  
  <ol>
  <li>My query is right or wrong?? if my query is wrong, please give me right query... Also if my query is almost right so please give me just "Add to cart" (<a href="http://prntscr.com/439lxj" rel="nofollow">http://prntscr.com/439lxj</a>) button dynamic Ajax code...</li>
  </ol>
  
  <p>Please help me... 
  Please help me... </p>
  
  <p>Thanks !!!</p>