Take the 2-minute tour ×
WordPress Development Stack Exchange is a question and answer site for WordPress developers and administrators. It's 100% free, no registration required.

I have a custom post type set up called 'projects' with a custom taxonomy called 'categories' that has a number of terms. For one of them called 'archive' i would like to remove its associated posts from the custom post loop. I'm attempting with the code below but doesn't seem to be excluding.

<?php $loop = new WP_Query( array( 'post_type' => 'projects', 'orderby'=>'rand', 'posts_per_page' => -1 ) ); 

query_posts( array(
'post_type' =>'projets',
'tax_query' => array( 
array( 'taxonomy' => 'categories', 'field' => 'slug', 'terms' => array( 'archive', ), 'operator' => 'NOT IN',),)
) );

<?php while ( $loop->have_posts() ) : $loop->the_post(); ?> POST CONTENT <?php endwhile; ?>
share|improve this question

1 Answer 1

this post has example code that excludes custom tax terms from a query, look it over in detail. it shows you how you can do what you're asking within a single query, without using query_posts.

the codex is pretty clear in regards to using query_posts and why it's a terrible idea.

share|improve this answer

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.