Advertisement
Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- <?php
- $params = array(
- 'posts_per_page' => 15,
- 'post_type' => 'product');
- $wc_query = new WP_Query($params); ?>
- <?php if ($wc_query->have_posts()) : ?>
- <?php while ($wc_query->have_posts()) : $wc_query->the_post(); ?>
- <?php the_title(); ?>
- <a href="<?php the_permalink(); ?>">
- <?php echo get_the_post_thumbnail($wc_query->post->ID); ?>
- </a>
- <?php echo $product->get_price_html(); ?>
- <?php echo apply_filters( 'woocommerce_loop_add_to_cart_link',
- sprintf( '<a rel="nofollow" href="%s" data-quantity="%s" data-product_id="%s" data-product_sku="%s" class="%s">%s</a>',
- esc_url( $product->add_to_cart_url() ),
- esc_attr( isset( $quantity ) ? $quantity : 1 ),
- esc_attr( $product->get_id() ),
- esc_attr( $product->get_sku() ),
- esc_attr( isset( $class ) ? $class : 'button' ),
- esc_html( $product->add_to_cart_text() )
- ),
- $product ); ?>
- <?php if ( $product->is_on_sale() ) : ?>
- <?php echo apply_filters( 'woocommerce_sale_flash', '<span class="onsale">' . esc_html__( 'Sale!', 'woocommerce' ) . '</span>', $post, $product ); ?>
- <?php endif; ?>
- <?php if ($product->get_average_rating() ):
- echo $product-> get_average_rating();
- endif; ?>
- <?php endwhile; ?>
- <?php wp_reset_postdata(); // (5) ?>
- <?php else: ?>
- <p>
- <?php _e( 'No Products' ); // (6) ?>
- </p>
- <?php endif; ?>
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement