Wordpress 从 WP 查询中排除自定义分类法类别
Wordpress exclude custom taxonomy category from WP Query
我试图从具有特定分类类别的自定义 post 类型中排除 posts,但它们不断出现:
<?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();
...
?>
然而它不起作用。我也试过 "NOT EXISTS" 作为操作员,但他们仍然出现。我的错误在哪里?
我想你必须使用下面的
taxonomy__not_in => 'linkcategory'
$args = array(
'post_type' => 'info_link',
'tax_query' => array(
array(
'taxonomy' => 'linkcategory',
'field' => 'slug',
'terms' => 'featured',
'operator' => 'NOT IN',
),
)
);
$query = new WP_Query( $args );
我试图从具有特定分类类别的自定义 post 类型中排除 posts,但它们不断出现:
<?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();
...
?>
然而它不起作用。我也试过 "NOT EXISTS" 作为操作员,但他们仍然出现。我的错误在哪里?
我想你必须使用下面的
taxonomy__not_in => 'linkcategory'
$args = array(
'post_type' => 'info_link',
'tax_query' => array(
array(
'taxonomy' => 'linkcategory',
'field' => 'slug',
'terms' => 'featured',
'operator' => 'NOT IN',
),
)
);
$query = new WP_Query( $args );