joshuatuscan
Member
Posted 2 years ago #
WordPress automatically includes both tags and categories in the RSS category tag when outputting the RSS2 for the site. I've figured out how to remove tags by deleting the line that includes them in the /wp-includes/feed.php file on line 315, but whenever wordpress is updated, this is reverted back to including tags.
How would you remove tags from the category RSS using the functions.php?
As you have realised, modifying core code is never a good idea; and usually unnecessary.
This is untried, but something like this should work..'
add_filter('get_the_tags', 'strip_tags_from_feeds');
function strip_tags_from_feeds($terms) {
if (is_feed())
return array();
return $terms;
}
joshuatuscan
Member
Posted 2 years ago #
Any way I can get a functional example of this code? Unfortunately my PHP skills are still in need of improvement.
Just tested it, and it will work exactly as I wrote.
Add that code to functions.php in your theme and the tags will not be included in the RSS feeds.
joshuatuscan
Member
Posted 2 years ago #
Thanks so much, been looking forever for this solution.
iPollesion
Member
Posted 1 year ago #
Thanks Mike, I was looking for this too.