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 need to select all posts from database without fetching some categories.
For example I fetch posts with this code:

$featuredPosts = new WP_Query();

So, now, how can i remove categories with id of: 22, 23 and 24?

share|improve this question
up vote 0 down vote accepted

Make query like this:

$query = new WP_Query( array( 'posts_per_page' => -1, 'category__not_in' => array( 2, 6 ) ) );

2, 6 being the category ID you want to exclude.

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.