Title: Multiple categries doesn&#039;t work | array(&#039;category&#039;=&gt; ?!
Last modified: August 22, 2016

---

# Multiple categries doesn't work | array('category'=> ?!

 *  [razzgpe](https://wordpress.org/support/users/razzgpe/)
 * (@razzgpe)
 * [11 years, 7 months ago](https://wordpress.org/support/topic/multiple-categries-doesnt-work-arraycategory/)
 * Hello,
 * I can’t solve my problem and can’t find any solution.
    I have a query and want
   only two catgories in it. “Neuigkeiten” & “Wettbewerbe”.
 * I did an array, but it doesn’t work:
 * `<?php $query = new WP_Query(array('category_name' => array('Neuigkeiten','Wettbewerbe'),'
   posts_per_page' => 4, )); while ($query->have_posts()): $query->the_post(); ?
   >`
 * This doesn’t work:
 * `<?php $query = new WP_Query(array('cat' => array('1','10'), 'posts_per_page'
   => 4, )); while ($query->have_posts()): $query->the_post(); ?>`
 * This doesn’t work:
 * `<?php $query = new WP_Query(array('category__in' => array('Neuigkeiten','Wettbewerbe'),'
   posts_per_page' => 4, )); while ($query->have_posts()): $query->the_post(); ?
   >`
 * Do you have any ideas?
 * Thank you.

Viewing 3 replies - 1 through 3 (of 3 total)

 *  [jherrington1](https://wordpress.org/support/users/jherrington1/)
 * (@jherrington1)
 * [11 years, 7 months ago](https://wordpress.org/support/topic/multiple-categries-doesnt-work-arraycategory/#post-5372891)
 * You need to do category__in but instead of the category name you need to do the
   ids.
 *  Thread Starter [razzgpe](https://wordpress.org/support/users/razzgpe/)
 * (@razzgpe)
 * [11 years, 7 months ago](https://wordpress.org/support/topic/multiple-categries-doesnt-work-arraycategory/#post-5372904)
 * Thanks, but that shows also the other categories, even array(‘1′,’10’)
 * `<?php $query = new WP_Query(array('category__in ' => array('1','10'), 'posts_per_page'
   => 4, )); while ($query->have_posts()): $query->the_post(); ?>`
 * Perhaps I can do the other way, how can I exclude a category?
    This doesn’t work:
 * <?php $query = new WP_Query(array( ‘cat ‘ => ‘-12’, ‘posts_per_page’ => 4, ));
   while ($query->have_posts()): $query->the_post(); ?>
 *  Thread Starter [razzgpe](https://wordpress.org/support/users/razzgpe/)
 * (@razzgpe)
 * [11 years, 7 months ago](https://wordpress.org/support/topic/multiple-categries-doesnt-work-arraycategory/#post-5372956)
 * Got it!
 * It works without ”
 * `<?php $query = new WP_Query(array('category__in ' => array(1,10), 'posts_per_page'
   => 4, )); while ($query->have_posts()): $query->the_post(); ?>`

Viewing 3 replies - 1 through 3 (of 3 total)

The topic ‘Multiple categries doesn't work | array('category'=> ?!’ is closed to
new replies.

## Tags

 * [categories](https://wordpress.org/support/topic-tag/categories/)
 * [category](https://wordpress.org/support/topic-tag/category/)
 * [post](https://wordpress.org/support/topic-tag/post/)
 * [query](https://wordpress.org/support/topic-tag/query/)
 * [query_post](https://wordpress.org/support/topic-tag/query_post/)

 * In: [Fixing WordPress](https://wordpress.org/support/forum/how-to-and-troubleshooting/)
 * 3 replies
 * 2 participants
 * Last reply from: [razzgpe](https://wordpress.org/support/users/razzgpe/)
 * Last activity: [11 years, 7 months ago](https://wordpress.org/support/topic/multiple-categries-doesnt-work-arraycategory/#post-5372956)
 * Status: not resolved

## Topics

### Topics with no replies

### Non-support topics

### Resolved topics

### Unresolved topics

### All topics
