我想使用WP_Query()
类来筛选我的一些帖子。我现在面临的问题是处理分类查询。通常WP_Query()
仅处理一个关系tax_query()
(或AND或or),但我需要的是在tax_query()
, 如何实现
eg
\'tax_query\' => array(
\'relation\' => \'AND\',
array(
\'taxonomy\' => \'taxonomy1\',
\'field\' => \'slug\',
\'terms\' => array( $term )
),
array(
\'taxonomy\' => \'taxonomy3\',
\'field\' => \'slug\',
\'terms\' => array( $term3 ),
\'operator\' => \'IN\',
)
// below i want to use OR relationship
\'relation\' => \'OR\',
array(
\'taxonomy\' => \'taxonomy4\',
\'field\' => \'slug\',
\'terms\' => array( $term4 )
),
array(
\'taxonomy\' => \'taxonomy2\',
\'field\' => \'slug\',
\'terms\' => array( $term2 ),
\'operator\' => \'IN\',
)
)
我知道上面的代码不起作用,我需要使用吗WP_Query()
要过滤吗?有什么想法吗?