Title: Exclude posts from certain category
Last modified: September 16, 2016

---

# Exclude posts from certain category

 *  [candell](https://wordpress.org/support/users/candell/)
 * (@candell)
 * [9 years, 10 months ago](https://wordpress.org/support/topic/exclude-posts-from-certain-category/)
 * I have a separate page for posts of a certain category, so I don’t want to show
   posts from that category in the standard loop
 * So I have on my archive template
 *     ```
       <?php query_posts('cat=-6'); ?>
   
       <?php if (have_posts()) : ?>
   
       <?php while (have_posts()) : the_post(); ?>
   
       Blah blah
   
       <?php endwhile; ?>
   
       <?php else : ?>
   
       <h1>Oops</h1>
   
       <?php endif; ?>
       ```
   
 * however this is still showing posts from category with ID 6.

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

 *  Moderator [t-p](https://wordpress.org/support/users/t-p/)
 * (@t-p)
 * [9 years, 10 months ago](https://wordpress.org/support/topic/exclude-posts-from-certain-category/#post-8191127)
 * [https://codex.wordpress.org/The_Loop#Exclude_Posts_From_Some_Category](https://codex.wordpress.org/The_Loop#Exclude_Posts_From_Some_Category)
   
   [https://codex.wordpress.org/Class_Reference/WP_Query](https://codex.wordpress.org/Class_Reference/WP_Query)
    -  This reply was modified 9 years, 10 months ago by [t-p](https://wordpress.org/support/users/t-p/).
 *  [Michael](https://wordpress.org/support/users/alchymyth/)
 * (@alchymyth)
 * [9 years, 10 months ago](https://wordpress.org/support/topic/exclude-posts-from-certain-category/#post-8192410)
 * better:
    [https://codex.wordpress.org/Plugin_API/Action_Reference/pre_get_posts#Exclude_categories_on_your_main_page](https://codex.wordpress.org/Plugin_API/Action_Reference/pre_get_posts#Exclude_categories_on_your_main_page)

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

The topic ‘Exclude posts from certain category’ is closed to new replies.

 * In: [Fixing WordPress](https://wordpress.org/support/forum/how-to-and-troubleshooting/)
 * 2 replies
 * 3 participants
 * Last reply from: [Michael](https://wordpress.org/support/users/alchymyth/)
 * Last activity: [9 years, 10 months ago](https://wordpress.org/support/topic/exclude-posts-from-certain-category/#post-8192410)
 * Status: not resolved

## Topics

### Topics with no replies

### Non-support topics

### Resolved topics

### Unresolved topics

### All topics
