Skip to content

Instantly share code, notes, and snippets.

@trueqap
Created June 18, 2020 15:20
Show Gist options
  • Star 0 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save trueqap/23dd3b05e7bbfef96d1534e85c65d215 to your computer and use it in GitHub Desktop.
Save trueqap/23dd3b05e7bbfef96d1534e85c65d215 to your computer and use it in GitHub Desktop.
List WooCommerce Product by Total sales
<?php
$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; ?>
<p>
<h3><?php the_title(); ?></h3>
</p>
<?php endwhile; ?>
<?php wp_reset_query(); ?>
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment