WordPress Development Stack Exchange is a question and answer site for WordPress developers and administrators. It's 100% free, no registration required.

Sign up
Here's how it works:
  1. Anybody can ask a question
  2. Anybody can answer
  3. The best answers are voted up and rise to the top

I'm querying multiple custom posts types and I'd like to filter certain posts that are tagged with a specific taxonomy term.

The taxonomy is "content" and the term is "indy"

I'm using the the code below.


// The Query
query_posts( array('post_type' => 'post', 'videos', 'music') );

// The Loop
while ( have_posts() ) : the_post(); ?>

<?php endwhile;
// Reset Query

How can I add that filter?

share|improve this question
is this the main query, or an additional query? what page is this query on? if this is the main query, have a look at pre_get_posts. also see taxonomy and post type parameters for WP_Query. – Milo Feb 26 '13 at 1:46

You should have a look at the arguments of WP_Query. The following arguments should be what you need. Note that tax_query takes an array of arrays.

$args = array(
  'post_type' => array( 'post', 'videos', 'music' ),
  'tax_query' => array(
       'taxonomy' => 'content',
       'field'    => 'slug',
       'terms'    => 'indy',
       'operator' => 'NOT IN' 

$myquery = new WP_Query( $args );
while( $myquery->have_posts() ):
  # do your stuff here
share|improve this answer
Worked perfectly, thanks. – Chozen Feb 27 '13 at 1:53

Your Answer


By posting your answer, you agree to the privacy policy and terms of service.

Not the answer you're looking for? Browse other questions tagged or ask your own question.