Skip to contentSkip to author details

Adding an RSS Icon to the “Subscribe to Comment RSS feed” link in a WordPress Template

Written by Michael Earls
 RSS  wordpress

In working with my custom template for WordPress, I came across an unfortunate problem. It seems that the default output for the function post_comments_feed_link() displays a simple anchor tag with a link to the comment RSS feed.

I like to use the RSS Icon (feed-icon-14x14) to indicate that the feed is, in fact, an RSS feed. It’s easily recognized over just plain text. This is not possible in the default implementation, so I had to do some hacking.

To get the icon on my page, I had to do two things:

  • Edit the *link-template.php *file in //wp-includes folder
  • Edit the style.css file

In link-template.php, search for the function named “post_comments_feed_link()”. Once you find that function, notice that the last line is:

echo applyfilters( ‘postcommentsfeedlinkhtml’, “$linktext”, $post_id, $feed );

Simply change it to the following code:

echo applyfilters( ‘postcommentsfeedlinkhtml’, “ id=’CommentRSSLink’>$linktext”, $post_id, $feed );

This will give us an ID to hook up with in our CSS file.

In your styles.css file, simply add the following:

background-image: url(‘img/feed-icon-14×14.png’);
background-repeat: no-repeat;
background-position: 0;
height: 14px;
padding-left: 18px;

Make sure you have the correct feed-icon (you can get them here) in the /img *folder.

You might also want to change your /comments.php to change the wording of the text, as demonstrated below.

Here’s the final result:


All in all, I’m finding WordPress to be very easy to enhance and extend. This change allowed me to offer my readers an easy to recognize way to subscribe to my comments’ RSS feeds.

I hope this helps.