We often find ourselves looking for the best and easiest way to exclude categories or pages from the navigation menu, the WordPress loop, the category list, the feed, the search, and/or the archive. It’s so easy to forget one of these elements and accidentally let that category slip into the blogstream. We actually wrote about a few WordPress plugins that exclude categories two years ago, but it’s definitely time to revisit this issue.

Recently, Miriam found an AMAZING plugin, Simply Exclude by Paul Menard, which is basically excluding heaven… if there is such a thing.

Exclude categories WordPress

Advanced Category Excluder vs. Simply Exclude

You may have come across the Advanced Category Excluder plugin, and wonder why we didn’t use that one. Here’s why:

Advanced Category Excluder (ACE) vs.  Simply Exclude:

  • Advanced Category Excluder conflicts with the Exclude Pages plugin (described below) which excludes pages  from the nav bar. Simple Exclude does not. When I activated it ACE all the pages that had been excluded with the Exclude Pages plugin appeared on the nav bar.
  • ACE also offers you to exclude Pages, which is so annoying since you have to go through a long list of all the pages on your site to see which you want to exclude, and they appear in long lists without any indication of parent pages and sub-pages. Also, there’s no easy way to exclude pages when you are adding or editing a page.
  • With ACE you have to first publish a post in a category, and only then will that category appear in the list of categories for exclusion. This means that if you want a category to not appear in the RSS feed etc., your first post in that category has to.

How to manually exclude categories in the theme files

And here are a few tips on how to exclude categories manually from the feed and the loop if you still prefer some good ol’ fashioned manual labor.

How to Manually Exclude a Category from a RSS feed

Place the following code in your functions.php file replacing 12 with your category and commas for additional categories. Tip from Web Kreation.

function myFeedExcluder($query) {

if ($query->is_feed) {

$query->set(‘cat’,’-12′);

}

return $query;

}

add_filter(‘pre_get_posts’,’myFeedExcluder’);

How to Manually Exclude a Category in Feedburner

Under Edit Feed Details add a ?cat=-93 or whatever the category ID number is so it comes out like:  http://domain.com/feed?cat=-93

How to Manually Exclude a Category from the Loop

Add this code BEFORE the loop and change 52 to whatever category you want to exclude

<?php query_posts(‘showposts=2&cat=-52’); ?>

Bonus: Easily Exclude Pages

Since we’re discussing excluding stuff from your WordPress blog, here’s a related plugin that we love called Exclude Pages by Simon Wheatley. It’s easy to use and great to give clients for excluding pages from their navigation menu. Exclude Pages adds a checkbox on the edit Page page that users can click to select to exclude the Page they are working on from any place that lists all Pages, like the navigation bar.