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

 
 
  • http://www.techpavan.com Pavan Kumar

    I remember of other plugins are feed control and feed control plus for many mods on feeds… Don’t know they are updated recently…

  • Samrat P

    looks like a article worth bookmarking.. I hadn’t tried category exclusion with RSS.. But I usually modify the theme to include or exclude certain categories to group the posts..

    Samrat Ps last blog post..Watch Your Laptop Battery Charge Below the Mouse With BattCursor

  • http://www.kimwoodbridge.com Kim Woodbridge

    Great article Raju! I use the plugin but the other methods look great too.

    Kim Woodbridges last blog post..Memories for Memorial Day

    • http://techpp.com Raju

      Thanks :)

  • http://techie-buzz.com Keith Dsouza

    I had written a plugin that allows users to selectively disable single posts from appearing in feeds, you can find more info here

    http://techie-buzz.com/wordpress-plugins/feed-pauser-individual-posts-update.html

    Keith Dsouzas last blog post..Hide Categories And Posts From Appearing On Homepage and Archives In WordPress

  • http://www.shoutmeloud.com Harsh Agrawal

    Great post Raju and it is very useful..
    Thanks for sharing , Submitted to Stumble

    @Kim which plugin do you use?

    Harsh Agrawals last blog post..5 websites to sell and buy websites-blogs

  • http://www.shoutmeloud.com Harsh Agrawal

    Is there any ways by which we can show post only in RSS feeds but not in actual blog post?

    Harsh Agrawals last blog post..WP super cache : WordPress optimization plugin

  • http://www.niharsworld.com/ Nihar

    Raju, great posts. I liked this very much. I have instances where i don’t want the post to be included in rss and also in home page.

    Nihars last blog post..How to Block Visitors from specific IP using .htaccess hack

  • Krish

    Hi Raju,

    Nice post and interesting to read. One of thing that I did recently with my RSS feed was to remove the junk URL and replaced it with my permalink. Actually this feature was already there in feedburner but I wasnt aware. If interested please do check out my blog on “How To Make Your Feed URL SEO Friendly”

    Cheers
    Krish

    Krishs last blog post..How To Make Your Feed URL SEO Friendly

  • http://ameyer.ch Andi Meyer

    Very good post with a lot of insight. Thanks.
    Lets assume I have a category norss that I exclude from appearing in my rss feed. Can you tell me what happens, when I publish the post and later edit it and remove the category norss from that link. Will it be published in the feed at that later date?

    I am actualy looking for a solution to set a topic in my blog with a short preview, then the following days editing and finalizing that post. I would like to show the revised version only in my rss feed. The above would be a nice workarount. But maybe someone sees an other solution for this problem?

    • http://techpp.com Raju

      @Andi Meyer,
      Interesting question!! I don’t think it will be published in the feed at the later date. But your feed archive will now contain this post as well (at the same date it was posted).

  • http://mikaeladanvers.com Mikaela

    Thanks for sharing, though 3. Exclude category from RSS feeds via FeedBurner did not work for me.

    I get this error:

    “An error occurred connecting to the URL: Error getting URL: 404 – Not Found”

  • http://www.skamid.com dimaks

    i have been wandering around for this and you just posted it.. thanks! this is what i needed. later i will try the plugin and see how it behaves with my blog.

  • Shurandy Thode

    Great article. I was looking for these long time already. Thanks for sharing.

  • http://www.happyschoolsblog.com HSB

    Awesome posts. I’m using Stealth Publish and it’s working like a charm.

  • http://mastersinusa.com phani

    Hi Raju,
    So happy to see an Indian national expertise in wordpress :)..all the best man

  • http://www.bdtechie.com Nasif

    Stealth publish is awesome. But I have a question, the post under stealth mode, are they going to be index by google ?

    • http://techpp.com Raju PP

      Yes, absolutely.

  • http://serious-things.com Serious Things

    FYI, under suggestion #3.. the URL needs the & replaced with a ? (at least on my end it did). So the final URL in the original feed field would look like this: http://domain.com/feed/?cat=-5

    The & symbol would error out, as the previous commenter mentioned.

    Thanks for the guide