我有一个名为news的自定义帖子类型。在内部,我有两个自定义分类法,称为新闻发布和媒体报道。当我使用此查询查询多个帖子时:
$args = array(
'post_type' => 'news',
'news_type' => 'press-releases',
'posts_per_page' => 15,
'paged' => $json_api->query->page,
);
$query = new WP_Query($args);
它只会将新闻帖子分类为我想要的新闻稿。但是,如果我指定了一个存在于media-coverage中的slug,它会返回该帖子,即使我已经指定了新闻发布分类。例如:
$args = array(
'name' => $slug,
'post_type' => 'news',
'news_type' => 'press-releases',
'posts_per_page' => 1,
);
答案 0 :(得分:0)
你可以试试这个
$args = array(
'post_type' => 'news',
'name' => '$slug,
'posts_per_page' => 1,
'tax_query' => array(
array(
'taxonomy' => 'news_type',
'field' => 'slug',
'terms' => 'press-releases'
)
)
);