我目前通過循環的所有帖子,並顯示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'=>'價格' –