Skip to content

Instantly share code, notes, and snippets.



Created Jun 18, 2020
What would you like to do?
List WooCommerce Product by Total sales
$args = array(
'post_type' => 'product',
'meta_key' => 'total_sales',
'orderby' => 'meta_value_num',
'posts_per_page' => 1,
$loop = new WP_Query( $args );
while ( $loop->have_posts() ) : $loop->the_post();
global $product; ?>
<h3><?php the_title(); ?></h3>
<?php endwhile; ?>
<?php wp_reset_query(); ?>
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
You can’t perform that action at this time.