WordPress的排除自定义分类类别从WP查询
问题描述:
我试图排除具有特定分类类别自定义后类型职位,但他们不断显示出来:WordPress的排除自定义分类类别从WP查询
<?php
$args = array(
'post_type' => 'info_link',
'taxonomy' => 'linkcategory',
'terms' => 'featured',
'operator' => 'NOT IN',
'orderby' => 'title',
'order' => 'ASC',
'posts_per_page' => '100',
);
query_posts($args);
if (have_posts()) : while (have_posts()) : the_post();
...
?>
但是它不工作。我也尝试过“不存在”作为运营商,但他们仍然出现。我的错误在哪里?
答
$args = array(
'post_type' => 'info_link',
'tax_query' => array(
array(
'taxonomy' => 'linkcategory',
'field' => 'slug',
'terms' => 'featured',
'operator' => 'NOT IN',
),
)
);
$query = new WP_Query($args);
答
我认为你必须使用下面
taxonomy__not_in => 'linkcategory'