Displaying Best Sellers Without A Plugin In WooCommerce

Looking to display the best selling products in your WooCommerce WordPress website? All you may need is to copy this example below.

Showing the best sellers in WooCommerce

To shop the best sellers in WooCommerce, simply copy and paste the code below to a page you’d like this displayed on and style accordingly.

<?php
$args = array(
     'post_type' => 'product',
     'meta_key' => 'total_sales',
     'orderby' => 'meta_value_num',
     'posts_per_page' => 5,
);
$loop = new WP_Query( $args );
while ( $loop->have_posts() ) : $loop->the_post(); 
global $product;
?>
<article class="best-seller">
     <?php echo get_the_post_thumbnail( $loop->post->ID, 'shop_catalog' ); ?>
     <a href="<?php the_permalink(); ?>"><?php the_title(); ?></a>
     <p><?php echo $product->get_sku(); ?></p>
     <p><?php echo $product->get_price(); ?></p>
     <?php do_action('front_cart_button'); ?>
</article>
<?php
endwhile;
wp_reset_query();
?>