Adding entry tags to your WordPress feeds

So my entries on here are tagged now (well, the new ones at least), but my feed templates did not have any tagging on them, and I couldn’t see any easy reference to get them included. 

I stumbled upon a handy hint that can be used to cram adverts into your feeds, and figured – with a bit of modification – that could work for tags, too.  Here is the code -

function dm_inserttags($content) {
    if(is_feed()) {
    $content = $content.
the_tags('<hr />This article is tagged with: ', ', ', '<hr />');   
    }
    return $content;  
}  
add_filter('the_content', 'dm_inserttags'); 

The original code hooked in on the_content_rss, but for whatever reason, that doesn’t seem to work.  (There are various open bugs about it not working.)  Instead you have to alter the_content and check if the output is a feed.  Put this into your theme’s functions.php and result – your feeds have tag links back to your blog.

This entry was posted in Blog, WordPress and tagged with , , .
Bookmark the permalink.
You can follow any comments here with the RSS feed for this post.
Both comments and trackbacks are currently closed.