Exclude Custom Taxonomies

Your tax_query is incorrect. taxonomy does not take an array.

taxonomy (string) - Taxonomy.

http://codex.wordpress.org/Class_Reference/WP_Query#Taxonomy_Parameters

You will need to rewrite your arguments to be more like the following from the Codex:

$args = array(
    'post_type' => 'post',
    'tax_query' => array(
        'relation' => 'AND',
        array(
            'taxonomy' => 'movie_genre',
            'field' => 'slug',
            'terms' => array( 'action', 'comedy' )
        ),
        array(
            'taxonomy' => 'actor',
            'field' => 'id',
            'terms' => array( 103, 115, 206 ),
            'operator' => 'NOT IN'
        )
    )
);
$query = new WP_Query( $args );

You can automate that a bit:

$taxonomies = array('miss_behave_category','emily_category','gemma_category','poppy_category');

$args = array(
  'post_type' => array( 'post', 'miss_behave', 'emily_davies','gemma_patel','poppy_smythe' ),
  'category__not_in' => 4
);

$args['tax_query']['relation'] = 'OR';
foreach ($taxonomies as $tax) {
  $args['tax_query'][] = array(
    'taxonomy' => $tax,
    'terms' => array(141,142,143,144),      
    'field' => 'id',
    'operator' => 'NOT IN' 
  );
}
// var_dump($args);

$the_query = new WP_Query($args);

However, “categories” are a taxonomony so you may as well include them in with the rest of the taxonomies, and all those NOT INs are not likely to be very efficient. I would carefully consider where those need to be included.

Leave a Comment