Title: query_posts(&#8220;cat=#&#8221;) not working
Last modified: August 19, 2016

---

# query_posts(“cat=#”) not working

 *  Resolved [the_tim](https://wordpress.org/support/users/the_tim/)
 * (@the_tim)
 * [17 years, 8 months ago](https://wordpress.org/support/topic/query_postscat-not-working/)
 * Okay I’m going crazy here. The following code works great:
 *     ```
       <?php	query_posts("tag=sometag");
       while(have_posts() && $i <= $posts_wanted) : the_post(); ?>
       ...
       [do stuff]
       ...
       <?php endwhile; ?>
       ```
   
 * But if I try to do the same loop and specify a category instead of a tag, it 
   returns all posts (not just posts in that category):
 *     ```
       <?php	query_posts("cat=3");
       while(have_posts() && $i <= $posts_wanted) : the_post(); ?>
       ...
       [do stuff]
       ...
       <?php endwhile; ?>
       ```
   
 * What is going on here? I’ve tried everything I can think of to get this to work
   and nothing seems to do the trick!

Viewing 1 replies (of 1 total)

 *  Thread Starter [the_tim](https://wordpress.org/support/users/the_tim/)
 * (@the_tim)
 * [17 years, 8 months ago](https://wordpress.org/support/topic/query_postscat-not-working/#post-843421)
 * All right so it turns out I thought of one more thing that I hadn’t tried.
 * I thought about what plugins I was using that mess with the categories, deactivated
   [Ultimate Category Excluder](http://www.planetmike.com/journal/plugins/ultimate-category-excluder/),
   and tried again.
 * Ta-da, everything works fine. So a word of warning to anyone using that plugin,
   it messes up the ability to properly run query_posts.

Viewing 1 replies (of 1 total)

The topic ‘query_posts(“cat=#”) not working’ is closed to new replies.

## Tags

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

 * In: [Fixing WordPress](https://wordpress.org/support/forum/how-to-and-troubleshooting/)
 * 1 reply
 * 1 participant
 * Last reply from: [the_tim](https://wordpress.org/support/users/the_tim/)
 * Last activity: [17 years, 8 months ago](https://wordpress.org/support/topic/query_postscat-not-working/#post-843421)
 * Status: resolved

## Topics

### Topics with no replies

### Non-support topics

### Resolved topics

### Unresolved topics

### All topics
