Title: Exclude from Widgets?
Last modified: August 21, 2016

---

# Exclude from Widgets?

 *  [Andrew Tegenkamp](https://wordpress.org/support/users/andrewteg/)
 * (@andrewteg)
 * [12 years, 7 months ago](https://wordpress.org/support/topic/exclude-from-widgets/)
 * This worked great to exclude a category from the archives but I also noticed 
   I had a month where that was the only post and it showed on my archives widget.
   Plus it was still on my categories widget, so I wanted to offer up this code 
   to exclude from the WP standard Categories and Archives widgets. If you have 
   another method let me know, and I hope this helps!
 *     ```
       /* exclude categories from category widget */
       add_filter("widget_categories_args","exclude_widget_categories");
       function exclude_widget_categories( $args ){
       	$args["exclude"] = '7'; //multiple = '7,8,9' using IDs from Posts=>Categories page in admin
       	return $args;
       }
   
       /* exclude categories from archive list widget */
       add_filter('getarchives_join','customarchives_join');
       add_filter('getarchives_where','customarchives_where');
       function customarchives_join($x) {
       	global $wpdb;
       	return $x." INNER JOIN $wpdb->term_relationships ON ($wpdb->posts.ID = $wpdb->term_relationships.object_id) INNER JOIN $wpdb->term_taxonomy ON ($wpdb->term_relationships.term_taxonomy_id = $wpdb->term_taxonomy.term_taxonomy_id)";
       }
       function customarchives_where($x) {
       	global $wpdb;
       	$exclude='7'; //multiple = '7,8,9' using IDs from Posts=>Categories page in admin
       	return $x." AND $wpdb->term_taxonomy.taxonomy = 'category' AND $wpdb->term_taxonomy.term_id NOT IN ($exclude)";
       }
       ```
   
 * [http://wordpress.org/plugins/ultimate-category-excluder/](http://wordpress.org/plugins/ultimate-category-excluder/)

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

 *  [Michael Clark](https://wordpress.org/support/users/planetmike/)
 * (@planetmike)
 * [12 years, 7 months ago](https://wordpress.org/support/topic/exclude-from-widgets/#post-4212286)
 * Thanks for the code. I’ll play with it after I’m finished moving. Realistically
   it probably won’t be experimented with until November.
 *  [iwriteplays](https://wordpress.org/support/users/iwriteplays/)
 * (@iwriteplays)
 * [12 years, 6 months ago](https://wordpress.org/support/topic/exclude-from-widgets/#post-4212468)
 * Thank you! This is exactly what I was looking for. Very helpful
 *  [moonhopper](https://wordpress.org/support/users/moonhopper/)
 * (@moonhopper)
 * [12 years, 6 months ago](https://wordpress.org/support/topic/exclude-from-widgets/#post-4212473)
 * Hi – looking interesting but I really need the solution Andrew appears to offer…
   where do you place that code Andrew? Do you have to manually edit those IDs in
   there or is there an admin panel/plug-in method for that?
 * Thanks in anticipation
 *  [Fra Calo](https://wordpress.org/support/users/frank-maio/)
 * (@frank-maio)
 * [11 years, 9 months ago](https://wordpress.org/support/topic/exclude-from-widgets/#post-4212491)
 * childtheme functions.php (@moonhopper)

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

The topic ‘Exclude from Widgets?’ is closed to new replies.

 * ![](https://ps.w.org/ultimate-category-excluder/assets/icon-256x256.png?rev=1352232)
 * [Ultimate Category Excluder](https://wordpress.org/plugins/ultimate-category-excluder/)
 * [Frequently Asked Questions](https://wordpress.org/plugins/ultimate-category-excluder/#faq)
 * [Support Threads](https://wordpress.org/support/plugin/ultimate-category-excluder/)
 * [Active Topics](https://wordpress.org/support/plugin/ultimate-category-excluder/active/)
 * [Unresolved Topics](https://wordpress.org/support/plugin/ultimate-category-excluder/unresolved/)
 * [Reviews](https://wordpress.org/support/plugin/ultimate-category-excluder/reviews/)

## Tags

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

 * 4 replies
 * 5 participants
 * Last reply from: [Fra Calo](https://wordpress.org/support/users/frank-maio/)
 * Last activity: [11 years, 9 months ago](https://wordpress.org/support/topic/exclude-from-widgets/#post-4212491)
 * Status: not resolved