Post Pic

How to: Suggest your visitors to leave comments in your rss feed

Most bloggers like to receive comments about their posts. Here is a cool recipe to display a message on your rss feed, notifying your visitors that the discussion is open and suggesting them to comment.

Additionally, when using WordPress as CMS, sometimes it is necessary to create new posts instead of pages for static pages because you want them to appear in the RSS feed. You may not want to enable comments inside those posts.

At other cases, you may also want to selectively choose to enable and disable comments. The problem is, how do you prevent your RSS feed subscribers from clicking with the intention to leave comment while the comment is disabled?

How about giving them a clue at the end of the post? To achieve this recipe, just put the following code in the functions.php file within your active theme:

function rss_comment_footer( $content ) {
    if ( is_feed() ) {
        if ( comments_open() ) {
            $content .= "\n\nComment is open. You can participate in the discussion
by visiting <a href='".get_permalink()."'>here</a>\n";
        }
    }
    return $content;
}

Thanks to Hendry Lee for submitting this recipe!

Related Posts

Related Posts

No related posts.

16 Responses

Feb 16 2009 09:25

Nice one,
But not really a guarantee that the community in your nitch with comment. But may help..

Feb 16 2009 14:22

tried it but it didn’t seem to work… not sure what i did wrong. I put it in the right place but… thanks anyways!

Feb 17 2009 06:13

I receive updates to your site via RSS. I didn’t see this in use at the bottom of your feed so I figured I didn’t need it either.

Feb 17 2009 07:35

@Tim Irvin: yeah, I don’t use all the tips I write here ;)

Feb 17 2009 20:01

I agree with WPCult, it does not guarantee to be successful, but at least it will help some.

Feb 22 2009 21:15

Didn’t work. I added it to my custom functions file and uploaded the new file to the server. Then I published a new post. Checked the feed . . . the new post is there, but the verbiage about comments is not.

It was a good idea, though.

Feb 24 2009 11:04

You should add following line also to your functions.php to actually call the function:

add_filter(‘the_content’, ‘rss_comment_footer’);

My question is that how to I make sure that my custom function is the latest thing added to feed? Some plugins add stuff to my feed and I want that comments option will be latest thing.

Mar 05 2009 12:36

Could you maybe post a pic how it looks when done? i don’t know if this will work that well – personaly I use my RSS reader in opera as exactly this – a reader. I don’t open posts in new window unless I have to (like explosm is only posting a link to the new comic instead of the comic itself). But maybe it’ll make couple more people comment so I’m not dismissing the idea completely.

Mar 13 2009 18:04

really appreciable. Its a really nice way to gather more and more comments on your post. thanks

Apr 08 2009 15:37

I think there’s a missing line here. Add this after the block code.

add_filter ('the_content', 'rss_comment_footer');

That should fix it.

Jun 05 2009 02:35

Really a useful simple piece of code. Also, we can make those statements or suggestions to be more enticing for them (the readers) to really participate on the discussion.

Feb 15 2010 06:07

Really useful code! I hope this will also be helpful to me!

Trackbacks:

Leave a Comment

* Name, Email, Comment are Required