0

我想在我的 WooCommerce 在线商店中获得收入最高的“最高收入者”。和

$top_10_products = new WP_Query(array("post_type" => "product", 
    "meta_key" => "total_sales", 
    "orderby" => "meta_value_num",
    "posts_per_page" => 10));

我得到了最畅销的产品。但是“高收入者”的元键是什么?

谢谢和最好的问候马丁

4

1 回答 1

0

试试下面的代码

$args = array(
    'post_type' => 'product',
    'meta_key' => 'total_sales',
    'orderby' => 'meta_value_num',
    'posts_per_page' => 10,
);
$Query = new WP_Query( $args );
while ( $Query->have_posts() ) : $Query->the_post(); 
global $product; 

if (has_post_thumbnail( $Query->post->ID )) 
        echo get_the_post_thumbnail($Query->post->ID, 'shop_catalog'); 
        else echo '<img src="'.woocommerce_placeholder_img_src().'" alt="product placeholder Image" width="65px" height="115px" />'; 

        the_title();

 endwhile; 
wp_reset_query(); 
于 2017-10-09T08:20:19.053 回答