Title: Query Posts Argument Selection
Last modified: August 21, 2016

---

# Query Posts Argument Selection

 *  [Farzanmc](https://wordpress.org/support/users/farzanmc/)
 * (@farzanmc)
 * [12 years, 10 months ago](https://wordpress.org/support/topic/query-posts-argument-selection/)
 * Hi.
 * This is what I want to do :
    Imagine that I have these categories for my posts.
 * Color
    – Red – Black – White
 * Year
    – 2011 – 2012 – 2013
 * Now I want to select “red and white” posts that are 2012.
 * Logically all the post that re “red and 2012” or “white and 2012”.
 * I tried cat , category__and and category__in , but no lock

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

 *  [vtxyzzy](https://wordpress.org/support/users/vtxyzzy/)
 * (@vtxyzzy)
 * [12 years, 10 months ago](https://wordpress.org/support/topic/query-posts-argument-selection/#post-3964773)
 * I think you can use a tax_query to do that. I have not tested this, but it should
   be close:
 *     ```
       $args = array(
       	'post_type' => 'post',
       	'tax_query' => array(
       		'relation' => 'AND',
       		array(
       			'taxonomy' => 'category',
       			'field' => 'slug',
       			'terms' => array( 'red', 'white' )
       		),
       		array(
       			'taxonomy' => 'category',
       			'field' => 'slug',
       			'terms' => array( '2012' ),
       			'operator' => 'IN'
       		)
       	)
       );
       $query = new WP_Query( $args );
       ```
   
 *  Thread Starter [Farzanmc](https://wordpress.org/support/users/farzanmc/)
 * (@farzanmc)
 * [12 years, 10 months ago](https://wordpress.org/support/topic/query-posts-argument-selection/#post-3964779)
 * Thank you vtxyzzy.
    So far so good. The first test returned the right results.
   Although I didn’t use ‘operator’ => ‘IN’ , but no difference. I’ll try to expand
   my code with different options and then put it here for anyone who has the same
   problem. Thanks again.

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

The topic ‘Query Posts Argument Selection’ is closed to new replies.

## Tags

 * [category](https://wordpress.org/support/topic-tag/category/)
 * [query_vars](https://wordpress.org/support/topic-tag/query_vars/)

 * In: [Fixing WordPress](https://wordpress.org/support/forum/how-to-and-troubleshooting/)
 * 2 replies
 * 2 participants
 * Last reply from: [Farzanmc](https://wordpress.org/support/users/farzanmc/)
 * Last activity: [12 years, 10 months ago](https://wordpress.org/support/topic/query-posts-argument-selection/#post-3964779)
 * Status: not resolved

## Topics

### Topics with no replies

### Non-support topics

### Resolved topics

### Unresolved topics

### All topics
