我想在我的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呢?
谢谢并向马丁致以最良好的问候
发布于 2017-10-09 16:20:19
尝试下面的代码
$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(); https://stackoverflow.com/questions/46641563
复制相似问题