How To Exclude A Category or Post From RSS Feed in WordPress


How To Exclude A Category From RSS Feed in WordPress:

You just need to add this code to your WP theme functions.php file:

<?php
function myFeedExcluder($query) {
 if ($query->is_feed) {
   $query->set('cat','-5');
 }
return $query;
}
 
add_filter('pre_get_posts','myFeedExcluder');
?>

In the above example –

-5

is the category ID I might want to exclude. :) – Pretty simple as it turned out.

We’ve built a subscription base of over 14,000 RSS subscribers with an interest in seo who expect a certain type of post to a particular schedule as a newsletter – but I also wanted the control of publishing posts that wouldn’t necessarily fit in with the normal seo related tips, and wouldn’t deluge my current subscribers with content they might not really want.

SO I wanted to be able to exclude a particular category from my RSS feed so I could publish more wordpress, web development and seo news type posts (like this one). :)

I can always do the odd round up post to let my subscribers know about this other content.

It could actually give me much greater control – perhaps if I publish something that’s popular, I can then have the option to promote to subscribers. Either way it’s more spider food for engines.

If it works.

RELATED ARTICLES

  1. The Best WordPress SEO Plugin
  2. Advice – Nofollow Blog Comments
  3. Do WordPress Self Pings Waste Pagerank?
  4. Host WordPress blog in a subdomain or directory?
  5. How To Exclude A Category or Post From RSS Feed in WordPress
  6. List Recent Posts From Single Category on Posts Within Same Category
  7. Add Text To Home Page Only on WordPress Blog
  8. WordPress Contact Form 7 Redirect To Thank You Page
  9. Speed Up Contact Form 7 Plugin For WordPress
  10. Dynamic PHP Copyright Notice in WordPress
  11. How To Import Large WordPress XML File Above Default Limit Size


Loading Facebook Comments ...

One Response

  1. Portland seo says:

    Not to make your beautiful WP snippet more complicated, but how do I subscribe to your snippet posts? I’m really, really into WP, Accessibility, web design, etc etc! A direct link to the category feed would be: ….example.com/category/post-url/feed I can’t find a list of your categories on your site. If you add a feed link to this post, We can subscribe to your snippets.



Learn how you can get more sales from your website

Subscribe for free and let us share with you:

  • how to submit your site to Google, Yahoo & Bing
  • how to optimise your site to get more traffic from Google
  • how to target the most valuable keywords for your business
  • how to make your site rank better in free Google listings
  • how to rank high & avoid Google penalties in 2014

Trust Hobo with your SEO plan

SEO Audit