我用两个“orderby”和wp\\u查询来显示酒店(我创建的分类法),但我没有成功。
结果如下:
Hotel 1 : 2 persons 5 stars
Hotel 2 : 2 persons 4 stars
Hotel 3 : 2 persons 3 stars
Hotel 4 : 3 persons 5 stars
Hotel 5 : 5 persons 5 stars
Hotel 6: 10 persons 2 stars
Hotel 7: 10 persons 1 star
第一个“order by”是指人数(第一个中最大的),第二个“order by”是指星级(因此,如果多家酒店的人数相同,星级最高的酒店将排在第一)。下面是我的代码。我尝试在带有meta\\u query的数组中添加一个数组,但没有成功。
$args=
array(
\'post_type\' => \'hotel\',
\'Services\' => $Services,
\'Town\' => $Town,
\'meta_key\' => \'Number_persons\',
\'orderby\' => \'meta_value_num\',
\'order\' => \'ASC\',
\'meta_query\' => array(
array(
\'meta_key\' => \'Rating\',
\'orderby\' => \'meta_value\',
\'order\' => \'DESC\',
)
)
);
$the_query = new WP_Query( $args );
非常感谢:)