X

Exclude categories

Adding this PHP code to your wordpress functions.php file will allow you to exclude categories from your RSS feeds. Make sure to use a minus - before the category id.

Code Snippet:


function excludeCat($query)
{
if ($query->is_feed)
{
$query->set('cat','-49′);
}
return $query;
}

add_filter('pre_get_posts','excludeCat');

Comments  Leave a Reply

  1. Shady M Rasmy April 5, 2012 at 1:48 am

    can i use it to exclude category from home page

Add a Comment

We're glad you have chosen to leave a comment. Please keep in mind that all comments are moderated according to our privacy policy, and all links are nofollow. Do NOT use keywords in the name field. Let's have a personal and meaningful conversation.

WordPress Launch Checklist

The Ultimate WordPress Launch Checklist

We've compiled all the essential checklist items for your next WordPress website launch into one handy ebook.
Yes, Send Me the Free eBook!