2

The following code is supposed to get posts that do not have specific terms in a custom taxonomy. At the moment it still gets them. Is something missing.

$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);
RIK
  • 17,723
  • 34
  • 107
  • 185

1 Answers1

2

Important Note: tax_query takes an array of tax query arguments arrays (it takes an array of arrays)

Wordpress Codex on Taxonomy Parameters

Have you tried?

$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);
Michael Kropat
  • 12,704
  • 9
  • 64
  • 85