我正在尝试对中的一些帖子进行筛选WP_Query
, 但我似乎没有得到正确的条件。基本上,我想做的是获取具有自定义字段的帖子event_data
(按此字段排序)并在这些帖子中仅选择填写了其中一个其他字段的帖子event_doc1
, event_doc2
, event_doc3
, main_doc
.
代码如下所示。
$metaCondition = array(
\'relation\' => \'OR\',
array(
\'key\' => \'main_doc\',
\'value\' => 0,
\'compare\' => \'!=\',
\'type\' => \'NUMBER\'
),
array(
\'key\' => \'event_doc1\',
\'value\' => 0,
\'compare\' => \'!=\',
\'type\' => \'NUMBER\'
),
array(
\'key\' => \'event_doc2\',
\'value\' => 0,
\'compare\' => \'!=\',
\'type\' => \'NUMBER\'
),
array(
\'key\' => \'event_doc3\',
\'value\' => 0,
\'compare\' => \'!=\',
\'type\' => \'NUMBER\'
)
);
$query = array(
\'numberposts\' => 4,
\'orderby\' => \'meta_value\',
\'meta_key\' => \'event_data\',
\'order\' => \'ASC\',
\'meta_query\' => $metaCondition
);
提前感谢大家!