我目前通过循环的所有帖子,并显示post_meta值是这样的:订购WordPress的post_meta - 最低到最高
global $wpdb;
$table = $wpdb->prefix . 'postmeta';
$theid = get_the_id();
$getLowestPrice = $wpdb->get_results("SELECT * FROM $table WHERE meta_value = '$theid'");
foreach ($getLowestPrice as $post){
get_post_meta($post->post_id, '_wholesale_price', false);
}
有没有办法命令的结果,最低 - >最高?目前,他们正在随机显示,或者在输入时显示。
您可以使用WP查询对于此类似如下 '$ query = new WP_Query(array('post_type'=>'product','orderby'=>'meta_value','meta_key'=>'price','order'=>'ASC' ));' –
我试过了,这只是得到一个连续的循环? – danyo
只是''meta_key'=>'_wholesale_price''在上述查询insteat'meta_key'=>'价格' –