Exclude categories from your rss feed

October 25, 2008 · Print This Article

Depending to your blog structure, it may be interesting to exclude some categories from your rss feeds.

Before starting to code, you’ll have to know the numeric ID of the categories you want to exclude.

Once you have the ID of the categories you want to exclude from your rss feed, open the functions.php file from your theme. If your theme doesn’t have a functions.php file, create one.

Paste the following code in it:
function myFilter($query) {
if ($query->is_feed) {
$query->set('cat','-5'); //Don't forget to change the category ID
}
return $query;
}

add_filter('pre_get_posts','myFilter');


Related articles:

Your choice for site templates and wordpress themes

Comments

Got something to say?

You must be logged in to post a comment.