WordPress.org

Ready to get started?Download WordPress

Forums

Remove post tags from category rss (6 posts)

  1. joshuatuscan
    Member
    Posted 3 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?

  2. Mike Little
    Member
    Posted 3 years ago #

    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;
    }
  3. joshuatuscan
    Member
    Posted 3 years ago #

    Any way I can get a functional example of this code? Unfortunately my PHP skills are still in need of improvement.

  4. Mike Little
    Member
    Posted 3 years ago #

    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.

  5. joshuatuscan
    Member
    Posted 3 years ago #

    Thanks so much, been looking forever for this solution.

  6. iPollesion
    Member
    Posted 2 years ago #

    Thanks Mike, I was looking for this too.

Topic Closed

This topic has been closed to new replies.

About this Topic