Created
June 18, 2020 15:20
-
-
Save trueqap/23dd3b05e7bbfef96d1534e85c65d215 to your computer and use it in GitHub Desktop.
List WooCommerce Product by Total sales
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
<?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