Advertisement
Guest User

Untitled

a guest
Jun 23rd, 2017
106
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
text 2.24 KB | None | 0 0
  1. <?php
  2. $params = array(
  3. 'posts_per_page' => 15,
  4. 'post_type' => 'product');
  5.  
  6. $wc_query = new WP_Query($params); ?>
  7.  
  8. <?php if ($wc_query->have_posts()) : ?>
  9. <?php while ($wc_query->have_posts()) : $wc_query->the_post(); ?>
  10.  
  11. <?php the_title(); ?>
  12. <a href="<?php the_permalink(); ?>">
  13. <?php echo get_the_post_thumbnail($wc_query->post->ID); ?>
  14. </a>
  15. <?php echo $product->get_price_html(); ?>
  16. <?php echo apply_filters( 'woocommerce_loop_add_to_cart_link',
  17. sprintf( '<a rel="nofollow" href="%s" data-quantity="%s" data-product_id="%s" data-product_sku="%s" class="%s">%s</a>',
  18. esc_url( $product->add_to_cart_url() ),
  19. esc_attr( isset( $quantity ) ? $quantity : 1 ),
  20. esc_attr( $product->get_id() ),
  21. esc_attr( $product->get_sku() ),
  22. esc_attr( isset( $class ) ? $class : 'button' ),
  23. esc_html( $product->add_to_cart_text() )
  24. ),
  25. $product ); ?>
  26.  
  27. <?php if ( $product->is_on_sale() ) : ?>
  28. <?php echo apply_filters( 'woocommerce_sale_flash', '<span class="onsale">' . esc_html__( 'Sale!', 'woocommerce' ) . '</span>', $post, $product ); ?>
  29. <?php endif; ?>
  30.  
  31. <?php if ($product->get_average_rating() ):
  32.  
  33. echo $product-> get_average_rating();
  34. endif; ?>
  35.  
  36. <?php endwhile; ?>
  37. <?php wp_reset_postdata(); // (5) ?>
  38. <?php else: ?>
  39. <p>
  40. <?php _e( 'No Products' ); // (6) ?>
  41. </p>
  42. <?php endif; ?>
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement