Few days back i write a tutorial on how to hide a categories posts from Home page without using any plugin, in the series of that we are going to discuss a way to hide categories from rss feeds without using any plugins.
How to hide categories from WordPress Feeds
1.In your current theme(template) files, open functions.php
2.Copy the below mention code in your functions.php file
<?php
function my_cat_exclude($query) {
if ($query->is_feed) {
$query->set(‘cat’,’-ID1,-ID2,-ID3′);
}
return $query;
}
add_filter(‘pre_get_posts’,’my_cat_exclude’);
?>
function my_cat_exclude($query) {
if ($query->is_feed) {
$query->set(‘cat’,’-ID1,-ID2,-ID3′);
}
return $query;
}
add_filter(‘pre_get_posts’,’my_cat_exclude’);
?>
add_filter(‘pre_get_posts’,’my_cat_exclude’);
?>
Where ID= your categories ID’s
Note: If you don’t want to digg into code, use this awesome plugin named as Advanced Category Excluder which not only hides the posts from displaying on home page but can also hides the posts from search results, your RSS feed, your category, your recent post, and from web crawlers.
Comments
10 responses to “How to hide a categories posts from wordpress RSS Feeds without using any plugin”