Title: Issue With query_posts()?
Last modified: August 20, 2016

---

# Issue With query_posts()?

 *  Resolved [faile486](https://wordpress.org/support/users/faile486/)
 * (@faile486)
 * [13 years, 10 months ago](https://wordpress.org/support/topic/issue-with-query_posts/)
 * I’m trying to display all the posts from a particular category.
 * This is the current code:
 *     ```
       query_posts( 'cat=news' );
   
        if (have_posts()) : while (have_posts()) : the_post(); ?>
         <a href="<?php the_permalink() ?>" style="font-size: 20px;"><?php the_title(); ?></a>
           <?php the_excerpt() ?>
   
       <?php endwhile; endif; ?>
       ```
   
 * news is the category slug. When using this code it’s returning every post, not
   the posts in that particular category. Anyone know what I’m doing wrong?

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

 *  [jon](https://wordpress.org/support/users/adiant/)
 * (@adiant)
 * [13 years, 10 months ago](https://wordpress.org/support/topic/issue-with-query_posts/#post-2931001)
 * A couple of problems:
    1. cat= is Category Number, not Category Slug
    2. `wp_reset_query();` is missing from the end, which will probably mess up your
       current Loop
 * Details on query_posts are here:
    [http://codex.wordpress.org/Function_Reference/query_posts](http://codex.wordpress.org/Function_Reference/query_posts)
 *  Thread Starter [faile486](https://wordpress.org/support/users/faile486/)
 * (@faile486)
 * [13 years, 10 months ago](https://wordpress.org/support/topic/issue-with-query_posts/#post-2931045)
 * Ah thanks! It should have been query_posts( ‘category_name=News’ );
 * Where does the wp_reset_quuery(); go? After the endif;?

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

The topic ‘Issue With query_posts()?’ is closed to new replies.

## Tags

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

 * In: [Fixing WordPress](https://wordpress.org/support/forum/how-to-and-troubleshooting/)
 * 2 replies
 * 2 participants
 * Last reply from: [faile486](https://wordpress.org/support/users/faile486/)
 * Last activity: [13 years, 10 months ago](https://wordpress.org/support/topic/issue-with-query_posts/#post-2931045)
 * Status: resolved

## Topics

### Topics with no replies

### Non-support topics

### Resolved topics

### Unresolved topics

### All topics
