WordPress Development Stack Exchange is a question and answer site for WordPress developers and administrators. Join them; it only takes a minute:

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 have a custom loop from a custom post type and I want to NOT display posts with the category 'slider'.

I'm using this to set up the query:

$args = array( 'post_type' => 'hotwives', 'posts_per_page' => -1);
$loop = new WP_Query( $args );
while ($loop->have_posts() ) : $loop->the_post();

I was going to use this in the $args variable:

'category' => 'slider'

But not sure how to make that NOT display the posts from category 'slider'.

And, incidentally, when I use that in the $args variable it still shows every post, not just the 'slider' posts. So, seems I'm not on the right track regardless.


share|improve this question
up vote 1 down vote accepted
$args = array(
    'posts_per_page' => -1,
    'post_type'      => 'hotwives',
    'post_status'    => 'publish',
    'tax_query'      => array(
            'taxonomy' => 'category',
            'field'    => 'slug',
            'terms'    => 'slider',
            'operator' => 'NOT IN'

Use that as the args for your WP_Query and you should get posts that aren't in the category taxonomy. It also has the advantage of being expansible to more than one exclude, etc. If you're using a custom taxonomy, change 'taxonomy''s value to the name of that taxonomy.

Docs: WP_Query

share|improve this answer
Good stuff. Works perfectly. Thanks for the detailed answer. – jw60660 Jan 17 '12 at 12:56

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.