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

---

# Exclude Posts Categoryfrom Recent Posts Widget

 *  [____](https://wordpress.org/support/users/prince09d/)
 * (@prince09d)
 * [12 years, 12 months ago](https://wordpress.org/support/topic/exclude-posts-categoryfrom-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');
       ```
   
 * However I am unable to do the same for my Widget.
 * Could anyone point me in the right direction? Thanks.

The topic ‘Exclude Posts Categoryfrom 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, 12 months ago](https://wordpress.org/support/topic/exclude-posts-categoryfrom-recent-posts-widget/)
 * Status: not resolved

## Topics

### Topics with no replies

### Non-support topics

### Resolved topics

### Unresolved topics

### All topics
