How to sort multiple wordpress custom field values?

后端 未结 4 1275
被撕碎了的回忆
被撕碎了的回忆 2021-02-06 12:47

Display posts with \'Product\' type ordered by \'Price\' custom field:

$query = new WP_Query( 
                      array ( \'post_type\' => \'product\', 
          


        
4条回答
  •  野的像风
    2021-02-06 13:04

    I think this changed slightly in Wordpress 3.7.

    I had to change

    return str_replace('menu_order', 'mt2.meta_value, mt1.meta_value', $orderby);
    

    into

    return str_replace('wp_posts.menu_order', 'mt2.meta_value, mt1.meta_value', $orderby);
    

    Thanks for the initial solution! [Edited]

提交回复
热议问题