在元查询中,还需要显式查询未设置该元键的帖子。通过嵌套元查询可以做到这一点,如下所示:
\'orderby\' => array(
\'meta_value_num\' => \'ASC\',
\'menu_order\' => \'ASC\'
),
\'meta_query\' => array(
\'relation\' => \'AND\',
array(
\'relation\' => \'OR\',
array(
\'key\' => \'newprice\',
\'type\' => \'decimal\',
),
array(
\'key\' => \'newprice\',
\'value\' => \'\',
\'compare\' => \'NOT EXISTS\',
),
),
array(
\'key\' => \'datum\',
\'compare\' => \'>=\',
\'value\' => strtotime(\'-1days\'),
),
),
另请注意,您需要设置
\'meta_key\'
在查询时
orderby
\'meta_value_num\'
它按正确的元键排序
实际上,如果你有meta_query
, 排除它将为您节省一个加入。