Support » Fixing WordPress » Exclude tags from the_category_rss() ?

  • Resolved jtonline


    In the WordPress Codex, the description of the function get_the_category_rss() is described as

    All of the categories for the current post in the feed loop, will be retrieved and have feed markup added…

    However, it’s not just retrieving the categories of the posts, it’s retrieving the tags I’ve associated with each post too.

    Is there a different function available that I could use in my feed-rss2.php file, or a hack that I could implement that would output only post categories to the WordPress rss2 feed?

Viewing 4 replies - 1 through 4 (of 4 total)
  • Just curious if you ever figured this out. I’d love to know the answer if you did.



    If you want to do this you will need to modify $WP_ROOT$/wp-includes/feed.php :

    Scroll down to “function get_the_category_rss($type = null)

    Inside that function there should be an if statement around line 315 that looks like “if ( !empty($tags) ) foreach ....

    Either comment that if statement out or delete it – all it is doing is adding the tag names as categories for it to parse when creating the categories.

    Not sure if this breaks anything, but I have been testing this for a project that required a <keywords> tag in the RSS feed so I removed it from the get_the_category_rss() function and created a new function that parses the tags and adds them as keywords in the RSS feed.


    Apologies for not acknowledging your reply until now. For some reason I neglected to subscribe to this topic and so didn’t get notified of any replies!

    I commented out the If statement in feed.php as you suggested, which has had the desired effect. I haven’t noticed any ill effects anywhere yet. Now when I look at the feed results in IE8 the ‘Filter by Category’ option just includes the post categories and not all the tags as well.

    Many thanks for your help.

    I created a solution without commenting the feed.php file.

    You can use your functions.php file to do so (the one in your theme folder). I created 5 hacks :

    • one that use only categories
    • one that use only one category
    • one that use only kewyords
    • one that use only one kewyord
    • one that use a custom taxonomy

    It’s just here : the_category_rss and wordpress RSS

Viewing 4 replies - 1 through 4 (of 4 total)
  • The topic ‘Exclude tags from the_category_rss() ?’ is closed to new replies.