Title: &#039;category__and&#039; with multiple input
Last modified: August 21, 2016

---

# 'category__and' with multiple input

 *  [chlustanec](https://wordpress.org/support/users/chlustanec/)
 * (@chlustanec)
 * [13 years, 1 month ago](https://wordpress.org/support/topic/category_and-with-multiple-input/)
 * Hi,
    I am wondering if I am able to get multiple input into ‘category__and’ (
   or ‘category’) argument separated by OR (or AND in ‘category’ case).
 * I have something like this:
 *     ```
       $args = array(
       	      'posts_per_page'  => '10',
       	      'numberposts'     => '',
       	      'offset'          => 0,
                     'category__and'   => $category_array,
       	      'orderby'         => 'post_date',
       	      'order'           => 'DESC',
       	      'post_type'       => 'post',
       	      'post_status'     => 'publish',
       	      'suppress_filters' => false );   
   
             $myposts2 = new WP_Query( $args );
       ```
   
 * And it works great. But yesterady, the task changed and user now can choose more
   options in one filter category. So I need change query to something like this:
 *     ```
       $args = array(
       	      'posts_per_page'  => '10',
       	      'numberposts'     => '',
       	      'offset'          => 0,
                     'category__and'   => <strong>$category_array_1 OR $category_array_2 OR $category_array_3</strong>,
       	      'orderby'         => 'post_date',
       	      'order'           => 'DESC',
       	      'post_type'       => 'post',
       	      'post_status'     => 'publish',
       	      'suppress_filters' => false );   
   
             $myposts2 = new WP_Query( $args );
       ```
   
 * I can make those combination earlier in the code, but, I cant get this **OR**
   thing working and I can’t find any solution neither (maybe I am just blind). 
   I am usualy capable to do my homewrok properly, but searchin for “OR” is kind
   of tricky…thanks for any help 🙂
 * EDIT: I can probably create a workaround with multiple queries, but I’d like 
   to have it in one query.

Viewing 1 replies (of 1 total)

 *  [vtxyzzy](https://wordpress.org/support/users/vtxyzzy/)
 * (@vtxyzzy)
 * [13 years ago](https://wordpress.org/support/topic/category_and-with-multiple-input/#post-3848077)
 * I think you can get what you want using a [tax_query](http://codex.wordpress.org/Class_Reference/WP_Query#Taxonomy_Parameters).
   Try replacing your ‘category__and’ entry with this:
 *     ```
       'tax_query' => array(
          'relation' => 'OR',
          array(
             'taxonomy' => 'category',
             'field' => 'id',
             'terms' => $category_array_1
          ),
          array(
             'taxonomy' => 'category',
             'field' => 'id',
             'terms' => $category_array_2
          ),
          array(
             'taxonomy' => 'category',
             'field' => 'id',
             'terms' => $category_array_3
          )
       ),
       ```
   

Viewing 1 replies (of 1 total)

The topic ‘'category__and' with multiple input’ is closed to new replies.

## Tags

 * [category_and](https://wordpress.org/support/topic-tag/category_and/)
 * [or](https://wordpress.org/support/topic-tag/or/)

 * In: [Fixing WordPress](https://wordpress.org/support/forum/how-to-and-troubleshooting/)
 * 1 reply
 * 2 participants
 * Last reply from: [vtxyzzy](https://wordpress.org/support/users/vtxyzzy/)
 * Last activity: [13 years ago](https://wordpress.org/support/topic/category_and-with-multiple-input/#post-3848077)
 * Status: not resolved

## Topics

### Topics with no replies

### Non-support topics

### Resolved topics

### Unresolved topics

### All topics
