我试图通过一个等于“new”或尚未设置的自定义字段筛选帖子。我可以让这些meta\\u查询中的任何一个单独工作,但当我在“OR”查询中使用它们时,“NOT EXISTS”部分将被忽略,查询将返回每个具有任何值集的帖子。下面是导致奇怪行为的示例“meta\\u query”:
array(
\'relation\' => \'OR\',
array(
\'key\' => \'status\',
\'compare\' => \'NOT EXISTS\',
),
array(
\'key\' => \'status\',
\'value\' => \'new\',
\'compare\' => \'=\',
),
);
SO网友:N. F.
array(
\'relation\' => \'OR\',
array(
\'key\' => \'status\',
\'value\' => \'\', //<--- not required but necessary in this case
\'compare\' => \'NOT EXISTS\',
),
array(
\'key\' => \'status\',
\'value\' => \'new\',
\'compare\' => \'=\',
),
);
That should do it.