1

I need to select all posts from database without fetching some categories.
For example I fetch posts with this code:

$featuredPosts = new WP_Query();
$featuredPosts->query('showposts=40');

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

0

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.

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service, privacy policy and cookie policy

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