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 exclude_category() {
if ( is_feed() ) {
set_query_var('cat', '-5');
}
}
add_filter('pre_get_posts', 'exclude_category');
?>
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.
Written by Shaun Anderson
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.