Off-late I have found some genuine reasons not to post some articles (or category of articles) on my site’s main feed. I believe many bloggers will have some reasons to exclude a post from their RSS feeds. It is beneficial in instances where you want to publish new content without any fanfare and just want the post added to archive and category pages and its own permalink page.

Top 5 Ways to Exclude Posts from Your WordPress RSS Feed

1. Change the feed URL

This might look like the easiest of the ways to exclude a WordPress category from RSS feed, but actually its not. I will tell you why later. This is done by changing the feed structure.




Normally the RSS link will look like this:

<a href="<?php bloginfo('rss2_url'); ?>">Entries (RSS)</a>

You can exclude any category by appending a query string to the feed URL, like this:

<a href="<?php bloginfo('url'); ?>/feed?cat=-5&cat=-10">Entries (RSS)</a>

where 5 & 10 are the IDs of the categories you want to be excluded from RSS feed. To identify the category ID, mouse-over the category name to see its ID in the status bar of your browser.

A more generic way to do will be:

<a href="<?php bloginfo('url'); ?>/feed=rss2&cat=-5,-10">Entries (RSS)</a>

Why this is not easy is, you would need to change the URL everywhere for it to work.

2. Exclude categories in your theme’s functions.php file

Just add the following code to your template’s functions.php file:

function myFilter($query) {
if ($query->is_feed) {
$query->set('cat','-5');
}

return $query;
}

add_filter(‘pre_get_posts’,’myFilter’);

That will keep category with ID 5 out of the feed. If you want to exclude more than one category, put them in separated by commas ‘-5,-10′.

Note: if you want to keep posts off the homepage, you use if ($query->is_home) instead of is_feed. Or you can do both with this: if ($query->is_home || $query->is_feed). Thanks Jangro for this tip.

3. Exclude category from RSS feeds via FeedBurner

Most of the bloggers use Feedburner and hence the first method I suggested above might not actually work. Go to your Feedburner dashboard and click “Edit Feed Details”. In the field “Original Feed”, enter the feed URL with the categories you want to exclude as explained in first method above.

exclude-category

4. Excluding categories with a plugin

If you are uncomfortable in coding/tweaking Template files, you can go for Ultimate Category Excluder plugin. It allows to exclude any categories from your front page, archives, and feeds. Once you installed it, go to the Category Exclusion page in your admin panel to exclude a category by selecting one.

5. Exclude individual posts instead of Categories

Rather than excluding an entire category from appearing in feeds, you may prefer to exclude a particular post from the RSS feed. In that case you can opt for Stealth Publish WordPress plugin by Scott Reilly. This plugin prevents specified posts from being featured on the front page or in feeds. After installing the plugin, simply assign a “stealth-publish” custom-field a value of “1”.

You have any other ideas to share? Do let me know.

 
Founder-Editor

Raju is the founder-editor of Technology Personalized. A proud geek and an Internet freak, who is also a social networking enthusiast. You can follow him on Facebook and on Twitter. Mail Raju PP. Follow rajupp