REALITYPOD
Realitypod

How to Remove a Category from RSS Feed – WordPress

A while ago, we started a category where users could submit videos and interesting links. But since those links/ videos were too many, it looked like junk to our RSS readers. Hence the only way to overcome this problem was to remove the particular category from our RSS feed. Although there are many plugins to do this job, it always better to add a line of code and solve the problem instead of adding junky codes into your website.

Problem

Remove Category from RSS Feed.

Solution

Add the following code in your functions.php file

function myFilter($query) {
if ($query->is_feed) {
$query->set(‘cat’,’-12′); //Don’t forget to change the category ID
}
return $query;
}

add_filter(‘pre_get_posts’,’myFilter’);

Note: In the above code, I have assumed that the category you wanted to remove from RSS feed was 12. To find your category ID in wordpress, follow this guide.

Related posts

Indians Condemning Apple For Launching iPhone 4S At A Much Higher Price

Realitypod

Father Spends 18 Months Building An Awesome Fairytale Treehouse For His Daughter In Her Room

Realitypod

10 Of The Most Awesome Teachers In The History Of School

Realitypod