Title: Exclude Posts Category from Recent Posts Widget
Last modified: August 21, 2016

---

# Exclude Posts Category from Recent Posts Widget

 *  [____](https://wordpress.org/support/users/prince09d/)
 * (@prince09d)
 * [12 years, 11 months ago](https://wordpress.org/support/topic/exclude-posts-category-from-recent-posts-widget/)
 * Hi,
 * I need to exclude a certain category of posts from my recent posts widget. This
   certain category is only used in Wooslider and its content is not relevant for
   my posts(news) page or recent posts widget.
 * I managed to exclude the posts from my posts-page by using the code:
 *     ```
       function exclude_category($query) {
       if ( $query->is_home() ) {
       $query->set('cat', '-xx');
       }
       return $query;
       }
       add_filter('pre_get_posts', 'exclude_category');
       ```
   
 * Yet I am unable to find the right code to do something similar for my recent 
   posts widget.
 * Could anyone offer some insight? Thanks!

The topic ‘Exclude Posts Category from Recent Posts Widget’ is closed to new replies.

 * In: [Fixing WordPress](https://wordpress.org/support/forum/how-to-and-troubleshooting/)
 * 0 replies
 * 1 participant
 * Last reply from: [____](https://wordpress.org/support/users/prince09d/)
 * Last activity: [12 years, 11 months ago](https://wordpress.org/support/topic/exclude-posts-category-from-recent-posts-widget/)
 * Status: not resolved

## Topics

### Topics with no replies

### Non-support topics

### Resolved topics

### Unresolved topics

### All topics
