Skip to content

Instantly share code, notes, and snippets.

@trueqap

trueqap/woo.php

Created Jun 18, 2020
Embed
What would you like to do?
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
You can’t perform that action at this time.