我花了一些时间才弄明白如何使用多个元键按数值排序,因为您不能只使用orderby meta\\u value\\u num。相反,您可以在元查询中将类型设置为numeric。这是有效的生产代码。
$meta_query = array(
\'relation\' => \'AND\',
\'query_one\' => array(
\'key\' => \'_rama_ads_type\'
),
\'query_two\' => array(
\'key\' => \'_rama_ads_order\',
\'type\' => \'NUMERIC\',
),
);
$order_by = array(
\'query_one\' => \'ASC\',
\'query_two\' => \'DESC\',
);
$query->set( \'meta_query\', $meta_query );
$query->set( \'orderby\', $order_by );