<?php
$args = array(
'post_type' => array( 'product' ),
'meta_key' => 'total_sales',
'orderby' => 'meta_value_num',
'order' => 'desc',
'posts_per_page' => 5
);
$popular_products = new WP_Query( $args );
if ( $popular_products->have_posts() ) :
while ( $popular_products->have_posts() ) : $popular_products->the_post();?>
<div class="recent-product grid-25 tablet-grid-50">
<a id="id-<?php the_id(); ?>" href="<?php the_permalink(); ?>" title="<?php the_title(); ?>">
<?php if (has_post_thumbnail( $loop->post->ID )) echo get_the_post_thumbnail($loop->post->ID, 'shop_catalog'); else echo '<img src="'.woocommerce_placeholder_img_src().'" alt="My Image Placeholder" width="65px" height="115px" />'; ?>
<h3><?php the_title(); ?></h3>
<!--<span class="price"><?php echo $product->get_price_html(); ?></span>-->
</a>
<!--<?php woocommerce_template_loop_add_to_cart( $loop->post, $product ); ?>-->
</div><!-- /recent-product -->
<?php
<?php endwhile; ?>
<?php wp_reset_query(); endif;?>
Last active
September 16, 2021 14:32
-
-
Save dasbairagya/9fb641ae71ea7643c5f24515974ea463 to your computer and use it in GitHub Desktop.
Woocommerce best sellers custom loop
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment