【发布时间】:2021-08-21 08:26:54
【问题描述】:
在我的网站上,有几个带有默认博客帖子的自定义帖子类型。在博客文章中,有很多类别。
其中一种帖子类型是webinar。我喜欢查询帖子类型webinar的所有帖子以及类别ID为43的博文
我尝试了以下方法但不起作用。
1:
$query = new WP_Query(array(
'post_type' => array('webinar'), // I need all post from webinar
'cat' => '43', // I need all blog post under this category (Post type post category id 43)
);
结果:未找到帖子
2:
$query = new WP_Query(array(
'post_type' => array('webinar','post'), // I need all post from webinar
'cat' => '43', // I need all blog post under this category (Post type post category id 43)
);
结果:只有类别 id 43 的帖子,没有帖子类型 webinar 的帖子
我需要类似以下的东西:
$query = new WP_Query(array(
array(
'relation' => 'OR',
array(
'post_type' => array('webinar')
),
array(
'post_type' => 'post',
'cat' => '43'
)
)
));
我该怎么做?
【问题讨论】:
标签: wordpress