Advertisement
Guest User

Untitled

a guest
Jul 24th, 2016
60
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
text 0.96 KB | None | 0 0
  1. <ul class="products">
  2. <?php
  3. $args = array('post_type' => 'product', 'posts_per_page' => 50, 'product_cat' => 'trousers', 'orderby' => 'rand');
  4. $loop = new WP_Query($args);
  5. while ($loop->have_posts()): $loop->the_post();global $product;?>
  6. <h2>Trousers</h2>
  7. <li class="product">
  8. <a href="<?php echo get_permalink($loop->post->ID) ?>" title="<?php echo esc_attr($loop->post->post_title ? $loop->post->post_title : $loop->post->ID); ?>">
  9. <?php woocommerce_show_product_sale_flash($post, $product);?>
  10. <?php if (has_post_thumbnail($loop->post->ID)) {
  11. echo get_the_post_thumbnail($loop->post->ID, 'shop_catalog');
  12. } else {
  13. echo '<img src="' . woocommerce_placeholder_img_src() . '" alt="Placeholder" width="300px" height="300px" />';
  14. }
  15. ?>
  16. <h3><?php the_title();?></h3>
  17. <span class="price"><?php echo $product->get_price_html(); ?></span>
  18. </a>
  19. <?php woocommerce_template_loop_add_to_cart($loop->post, $product);?>
  20. </li>
  21. <?php endwhile;?>
  22. <?php wp_reset_query();?>
  23. </ul><!--/.products-->
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement