2

以下代码应该获取自定义分类中没有特定术语的帖子。目前它仍然得到他们。是不是缺少了什么。

$args = array(
            'numberposts' => '3',
            'post__not_in' => $post_not_in,
            'tax_query' => array(
                'taxonomy' => 'topic',
                'terms' => 9,      
                'field' => 'id',
                'operator' => 'NOT IN'
            ) 
        ); 
        $extras = get_posts($args);
4

1 回答 1

2

重要提示: tax_query 接受一个税查询参数数组的数组(它接受一个数组数组)

关于分类参数的 Wordpress 法典

你有没有尝试过?

$args = array(
    'numberposts' => '3',
    'post__not_in' => $post_not_in,
    'tax_query' => array(
        array(
            'taxonomy' => 'topic',
            'terms' => 9,      
            'field' => 'id',
            'operator' => 'NOT IN'
        )
    )
); 
$extras = get_posts($args);
于 2014-01-29T15:26:21.130 回答