Title: Only posts from one Category
Last modified: August 20, 2016

---

# Only posts from one Category

 *  Resolved [idesign123](https://wordpress.org/support/users/idesign123/)
 * (@idesign123)
 * [15 years, 2 months ago](https://wordpress.org/support/topic/only-posts-from-one-category/)
 * I’m still pretty new to WordPress and am trying to figure out how to show posts
   just from one category.
 * I did find some code snippets, but am not sure how to apply to my particular 
   chunk of code.
 * Here is what I have right now…
 *     ```
       <?php if (have_posts()) : ?>
       <?php wp_reset_query(); ?>
   
       <?php $paged = (get_query_var('paged')) ? get_query_var('paged') : 1; ?>
        <?php query_posts("paged=$paged"); ?>
       ```
   
 * How would I modify this so only posts from category #21 would show up?
 * Thank you for your help 🙂

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

 *  [esmi](https://wordpress.org/support/users/esmi/)
 * (@esmi)
 * [15 years, 2 months ago](https://wordpress.org/support/topic/only-posts-from-one-category/#post-2094757)
 *     ```
       <?php
       $paged = (get_query_var('paged')) ? get_query_var('paged') : 1;
       $args= array(
       	'cat' => 21,
       	'paged' => $paged
       );
       query_posts($args);
       if (have_posts()) :
       ?>
       ```
   
 *  Thread Starter [idesign123](https://wordpress.org/support/users/idesign123/)
 * (@idesign123)
 * [15 years, 2 months ago](https://wordpress.org/support/topic/only-posts-from-one-category/#post-2094760)
 * Yes, that did the trick!
    Thank you so much 😀
 *  Thread Starter [idesign123](https://wordpress.org/support/users/idesign123/)
 * (@idesign123)
 * [15 years, 2 months ago](https://wordpress.org/support/topic/only-posts-from-one-category/#post-2094807)
 * Oops, looks like I need one more minor tweak…
 * Can this be adjusted so instead of showing posts from category 21, it shows posts
   from all categories EXCEPT categories #1 & 5?
 * After that tweak, it should work perfectly.
 * _[[No bumping, please](http://codex.wordpress.org/Forum_Welcome#No_Bumping).]_

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

The topic ‘Only posts from one Category’ is closed to new replies.

## Tags

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

 * In: [Fixing WordPress](https://wordpress.org/support/forum/how-to-and-troubleshooting/)
 * 3 replies
 * 2 participants
 * Last reply from: [idesign123](https://wordpress.org/support/users/idesign123/)
 * Last activity: [15 years, 2 months ago](https://wordpress.org/support/topic/only-posts-from-one-category/#post-2094807)
 * Status: resolved

## Topics

### Topics with no replies

### Non-support topics

### Resolved topics

### Unresolved topics

### All topics
