How to get just the common posts of 2 different categories? consider this category tree:


Now I want to get the posts in categories 'news' and 'region2'. I have tried this:

$query = new WP_Query('category__and=12,32'); // 12=news, 32=region2

But then I get all the posts which have either category 12 or category 32. I want those posts which have both 12 and 32.

1 Answer 1


category__and needs to be an array of category ID's

category__and (array) - use category id.

You can modify your code to look like this

$query = new WP_Query( array('category__and' => array(12,32)));

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge you have read our privacy policy.

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