我已经对我的定制模板进行了自定义查询,我想用价格范围按特定类别显示产品,就像我有10个产品一样。价格是$10,$20,$15,$25等等。现在我想向大家展示这个产品的价格从低到高。示例10,15,20,25,类似于排序系统。这是我的查询代码。请与查询代码共享我需要添加的代码,以显示低到高。
'product',
'posts_per_page' => 10,
'product_cat' => 'combinations',
);
$comba = new WP_Query($com_query);
if($comba->have_posts()) : while($comba->have_posts()) : $comba->the_post();
$com_size = get_post_meta(get_the_ID(), 'combinations-size', true);
$com_food_menus = get_post_meta(get_the_ID(), 'combinations-food-menus', true);
?>
';
}
?>
Price : get_price_html(); ?>
Size :
post->post_excerpt; ?>
Food Menus:
$food_menu";
}
?>发布于 2018-02-17 08:49:54
$args = array(
'post_type' => 'product',
'posts_per_page' => 10,
'orderby' => 'meta_value_num',
'meta_key' => '_price',
'order' => 'asc'
);
$loop = new WP_Query( $args );
echo '';
while ( $loop->have_posts() ) : $loop->the_post();
global $product;
echo '';
echo ' ';
echo '' . woocommerce_get_product_thumbnail().' '.get_the_title().'';
echo '';
/* echo '
' . woocommerce_get_product_thumbnail().' '.get_the_title().'';*/
endwhile;
echo '';
wp_reset_query();https://wordpress.stackexchange.com/questions/294360
复制相似问题