Title: Posts from all Categories except 2
Last modified: August 20, 2016

---

# Posts from all Categories except 2

 *  Resolved [idesign123](https://wordpress.org/support/users/idesign123/)
 * (@idesign123)
 * [15 years, 2 months ago](https://wordpress.org/support/topic/posts-from-all-categories-except-2/)
 * I have the following code snippet…
 *     ```
       <?php
       $paged = (get_query_var('paged')) ? get_query_var('paged') : 1;
       $args= array(
       	'cat' => 21,
       	'paged' => $paged
       );
       query_posts($args);
       if (have_posts()) :
       ?>
       ```
   
 * This code works great – showing all the posts in category #21.
 * I need to change it though…
    What I need now is to show posts from all categories
   EXCEPT categories #1 & 5.
 * Can someone please show me what would need to be modified in my code to do this?

Viewing 1 replies (of 1 total)

 *  Thread Starter [idesign123](https://wordpress.org/support/users/idesign123/)
 * (@idesign123)
 * [15 years, 2 months ago](https://wordpress.org/support/topic/posts-from-all-categories-except-2/#post-2095340)
 * Hey, I figured out my own question 🙂
 * Just change it to…
    ‘cat’ => -1,-5
 * Hopefully that helps someone.

Viewing 1 replies (of 1 total)

The topic ‘Posts from all Categories except 2’ is closed to new replies.

 * In: [Fixing WordPress](https://wordpress.org/support/forum/how-to-and-troubleshooting/)
 * 1 reply
 * 1 participant
 * Last reply from: [idesign123](https://wordpress.org/support/users/idesign123/)
 * Last activity: [15 years, 2 months ago](https://wordpress.org/support/topic/posts-from-all-categories-except-2/#post-2095340)
 * Status: resolved

## Topics

### Topics with no replies

### Non-support topics

### Resolved topics

### Unresolved topics

### All topics
