Title: Trouble with query_posts( )
Last modified: August 18, 2016

---

# Trouble with query_posts( )

 *  [shnafoo](https://wordpress.org/support/users/shnafoo/)
 * (@shnafoo)
 * [18 years, 7 months ago](https://wordpress.org/support/topic/trouble-with-query_posts/)
 * I would like to make a custom query that checks to see if a post is in two categories.
   Something like: A ‘and’ B…
 * What is the query_posts() syntax for this? You can see my attempt below which
   does not work. I’m using this to separate news articles from different years.
 *     ```
       <?php if (is_page('84')) { ?>
       			<?php query_posts('category_name=inthenews&showposts=10'); ?>
   
       		<?php } elseif (is_page('90')) { ?>
       		<?php query_posts('category_name=inthenews && category_name=2007'); ?>
   
       		<?php } elseif (is_page('91')) { ?>
       		<?php query_posts('category_name=inthenews && category_name=2006'); ?>
   
       		<?php } elseif (is_page('92')) { ?>
       		<?php query_posts('category_name=inthenews && category_name=2005'); ?>
   
       		<?php } ?>
       ```
   

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

 *  Thread Starter [shnafoo](https://wordpress.org/support/users/shnafoo/)
 * (@shnafoo)
 * [18 years, 7 months ago](https://wordpress.org/support/topic/trouble-with-query_posts/#post-616643)
 * … This might actually work. I’ll get an update soon.
 *  [tupto](https://wordpress.org/support/users/tupto/)
 * (@tupto)
 * [18 years, 2 months ago](https://wordpress.org/support/topic/trouble-with-query_posts/#post-616920)
 * What your looking for is here [http://codex.wordpress.org/Template_Tags/next_post_link](http://codex.wordpress.org/Template_Tags/next_post_link)

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

The topic ‘Trouble with query_posts( )’ is closed to new replies.

## Tags

 * [query](https://wordpress.org/support/topic-tag/query/)
 * [query_posts](https://wordpress.org/support/topic-tag/query_posts/)

 * 2 replies
 * 2 participants
 * Last reply from: [tupto](https://wordpress.org/support/users/tupto/)
 * Last activity: [18 years, 2 months ago](https://wordpress.org/support/topic/trouble-with-query_posts/#post-616920)
 * Status: not resolved

## Topics

### Topics with no replies

### Non-support topics

### Resolved topics

### Unresolved topics

### All topics
