Title: Exclude Category
Last modified: August 19, 2016

---

# Exclude Category

 *  Resolved [thisisedie](https://wordpress.org/support/users/thisisedie/)
 * (@thisisedie)
 * [15 years, 1 month ago](https://wordpress.org/support/topic/exclude-category-6/)
 * I’ve used this code before and it worked fine but for some reason when I drop
   this in the functions.php it no longer works. Has something changed in the new
   version of WP that’s preventing it from working? I’m using no plugins and it 
   doesn’t work with the Twentyten theme either. Thanks :o)
 *     ```
       function exclude_category($query) {
       if ($query->is_home || $query->is_archive || $query->is_search || $query->is_feed) {
       $query->set('cat', '-12');
       }
       return $query;
       }
       add_filter('pre_get_posts', 'exclude_category');
       ```
   
 * Nevermind. Found the answer near the end of the comments [here](http://blogmum.com/2009/04/how-to-exclude-categories-from-the-home-page-of-your-wordpress-blog/).

The topic ‘Exclude Category’ is closed to new replies.

## Tags

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

 * In: [Fixing WordPress](https://wordpress.org/support/forum/how-to-and-troubleshooting/)
 * 0 replies
 * 1 participant
 * Last reply from: [thisisedie](https://wordpress.org/support/users/thisisedie/)
 * Last activity: [15 years, 1 month ago](https://wordpress.org/support/topic/exclude-category-6/)
 * Status: resolved

## Topics

### Topics with no replies

### Non-support topics

### Resolved topics

### Unresolved topics

### All topics
