Blog
Categories: Code, Web Development, Wordpress
Exclude a Category from your RSS Feed in WordPress
Posted on September 21, 2010, at 10:35 pm

Thanks to my friend Andrew (a la Scurvy Design), I discovered this morning a flaw in the way my “On the Go” post images were displaying in Google Reader. They were blowing way out of the window size and it looked horrible. So I opted to find a way to remove those posts from my feed.

A little bit of research found a method to add a filter to your RSS feed:

1
2
3
4
5
6
7
function feedFilter($query) {
	if ($query->is_feed) {
		$query->set('cat', '-375');
	}
	return $query;
}
add_filter('pre_get_posts','feedFilter');

The “375″ is the numerical ID of the category you want to exclude. You can exclude multiple categories by separating them with commas, i.e. set(‘cat’, ‘-375,-3,-8′).

This code needs to be placed in your “functions.php” file.

It’s a bit annoying that Google reader caches everything it sees. What do you do when you have test posts make make their way into the cache? Though ultimately, I think it’s a good thing. If a well-known villain were to post something awful, and it were to get picked up by Google reader, it would be that much harder to hide.

More Updates...
  • Klick Holiday Video I’ve only been with Klick for a short time but it’s been a great place to work. We put together this video for the holiday season. It’s the best yet!
  • Martin Amis on the nervous breakdown of the GOP
  • “Communicating with James was difficult.” New York Times profile of a deeply troubled man.
  • Bill Nye on Creationism: It’s not appropriate for children!
  • How to Suck at Your Religion A cartoon by The Oatmeal
  • Texas claims abandoned Walmart and turns it into an award-winning library.
  • Beer Cocktails. Learn a bit of history about the Shandygaff!
  • In Mumbai, a man points out people are drinking sewage water. He now faces charges and arrest.
  • See more...
    © 2013 Blair Kelly