我希望在我的WooCommerce在线商店中获得收入最高的“收入最高的人”。与
$top_10_products = new WP_Query(array("post_type" => "product",
"meta_key" => "total_sales",
"orderby" => "meta_value_num",
"posts_per_page" => 10));
我得到了最畅销的产品。但是“顶级收入者”的meta_key是什么?
感谢和最好的问候马丁
答案 0 :(得分: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();