ron rothman.ron rothman
selectively conformist

WordPress Plugin: Recent Love (A List of Recent Comments)

Plugin Name:Recent Love
Plugin Author:Ron Rothman
Description:Presents a list of recent comments, one comment per post.
Latest Version:0.5 (Updated April 4, 2007)
Download:txt phps zip 

A few months ago, I wanted to display a list of recent comments in my blog’s sidebar. After searching through the countless plugins which return lists of comments, I finally decided on Scott Reilly’s Top/Recent Commenters plug-in.

Unfortunately, I had to tweak Scott’s code to get it to work the way I wanted. One tweak led to another (you know how it is) until I finally just scrapped the original code and rolled my own. (You can see it in action on my blog’s front page.)

What It Does

Adds template function:

rr_recent_comments ($num_recent_posts = 5, $before = '<li>', $after = '</li>')

rr_recent_comments() returns a list of recent comments.

When invoked with no parameters, it returns a list of the latest comment from each of the most recent 5 posts. Only one comment (the most recent one) per post is listed.

By default, any comments made by the author of the post are not included in the list. (This behaviour can be configurably modified.) Long post titles are truncated to a length which you can configure. Trackbacks and pingbacks are not included in the list by default.

You can exlcude certain posters, based on various criteria (author email, author name, etc.). This is helpful, for example, to exclude yourself from the list.

How to Install It

  1. Requirements: WordPress 1.5 or greater (verified to work on 1.5.2, 2.0, 2.0.1, 2.2, 2.2.2, 2.2.3, 2.3.2, 2.3.3, 2.5.1, 2.6.0, 2.6.1, 2.7, 2.8.x, 2.9.1, 2.9.2)
  2. Download the plugin file, and put it file in your WordPress plugin directory, wp-content/plugins. (Make sure to name it rr_recent_love.php.
  3. Enable the plugin in the WordPress Plugin Admin panel.

How to Use It

Just insert the following call into your theme files, wherever you want the comment list to appear (e.g., sidebar.php):

<ul class='recent_comments'>
    <?php echo rr_recent_comments(); ?>
</ul>

You can customize your list two ways: tag parameters and global config options.

Parameters

rr_recent_comments() takes three parameters, all of which are optional.

  1. $num_recent_posts

    The [maximum] number of comments to display.
    Default: 5

  2. $before

    The text to display before each comment.
    Default: ‘<li>’

  3. $after

    The text to display after each comment.
    Default: ‘</li>’

Configuration Options

The behaviour of rr_recent_comments() can be customized on a global basis by editing some values in the plugin file, rr_recent_comments.php. With the possible exception of $max_title_length, most installations will probably not need to futz with these, but they’re there if you want ’em.

  • $max_title_length (Default: 38)

    This value represents the longest length that a post title may be without it being truncated for display. Titles longer than this will be indiscriminately chopped, and an ellipses will be appended to them. Set to 0 to disable truncation altogether (not recommended).

  • $exclude_authors_comments (Default: true)

    Set to true to exclude an author’s comments from his/her own posts. Set to false to include them.

  • $link_to_commenters_websites (Default: true)

    Set to true to hyperlink the comment author’s name to the website they enter on your comment form. Set to false to suppress hyperlinking.

  • $suppress_trackbacks (Default: true)

    If true, trackbacks and pingbacks are excluded from the comment list. Set to false to include them.

  • $identify_authors_by and $excludes_sql_list (Default: no exclusions)

    These two fields work in conjunction to allow you to specify a list of comments whose comments should never be included in the list. (Note that most blog installation will not need to use this functionality.) First, choose the criterion by which you want to identify the excluded comments and set $identify_authors_by to one of:

    • 'comment_author',
    • 'comment_author_url' or
    • 'comment_author_email'.

    Then add the excluded commenters to the list $excludes_sql_list; be careful to follow the correct format, which is:
    ('COMMENTER_1', 'COMMENTER_2', ..., 'COMMENTER_N').

    You must specify the COMMENTERs in a way that matches the value of $identify_authors_by. I.e., if $identify_authors_by is 'comment_author_email', then the COMMENTERs in $excludes_sql_list must all be email addresses.

Revision History

0.1 (May 1, 2005): Initial revision.

0.2 (October 30, 2005): Rewrite and add new features.

0.3 (November 11, 2005): Clean up for publication.

0.4 (?)

0.5 (April 4, 2007): Added $link_to_commenters_websites option.

See It Live

Here are some of the sites which are using Recent Love (as of the time of this writing):

Important Disclaimers and Such

Summary

  1. You may freely use and distribute this code as long as you include the appropriate copyright notice.
  2. If anything bad happens as a result of your using this code, don’t come crying to me. If anything good happens as a result of your using this code, send me some chocolate.

Details

Copyright © 2005-2007 by Ron Rothman and «leftbraned. Some rights reserved.

Permission is hereby granted, free of charge, to any person obtaining a copy of this software and associated documentation files (the “Software”), to deal in the Software without restriction, including without limitation the rights to use, copy, modify, merge, publish, distribute, sublicense, and/or sell copies of the Software, and to permit persons to whom the Software is furnished to do so, subject to the following conditions:

The above copyright notice and this permission notice shall be included in all copies or substantial portions of the Software.

THE SOFTWARE IS PROVIDED “AS IS”, WITHOUT WARRANTY OF ANY KIND, EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE.

60 Responses to “WordPress Plugin: Recent Love (A List of Recent Comments)” [Leave yours »]

  1. Ron [author of post] said:

    oops, this morning i discovered a subtle bug. fixed.

    1
  2. Beautiful plugin. I have been looking for something like this for months. Thank you very much.

    2
  3. Ron [author of post] said:

    my pleasure–glad you found it useful! let me know if you have any issues with it or any requests.

    (i’ll look for it in your sidebar soon. :) )

    3
  4. Ron [author of post] said:

    ugh, found a [minor] bug in the truncation of post names. fixed, and released in version 0.4. sorry for any trouble!

    to apply the fix manually to 0.3, just change line 223 of rr_recent_love.php from

    $post_title = htmlspecialchars(substr($post_title, $max_title_length)) . '…';

    to

    $post_title = htmlspecialchars(substr($post_title, 0, $max_title_length)) . '…';

    4
  5. I know part of your integral functionality was posting just one per topic, but is it possible to add an option that toggles that on or off? I’d like to see all posts made :)

    5
  6. Ron [author of post] said:

    hmm, i’ll see what i can do. but i think what you’re asking for is different enough from the current functionality that i’d end up writing a new plugin entirely (or at least a new template function).

    thanks for the idea. i’ll email you and update this thread when the next version is ready. (probably not til next year–so don’t hold your breath or you might die. :D )

    6
  7. […] Ursprüglich wollte ich das mit dem neuen Plugin von Zappelfillip machen – allerdings funktionierte das bei mir nicht. Daher nahm ich dann “Recent Love” was vom Prinzip her das selbe macht.. […]

    7
  8. Thanks for the great plugin, works a treat! Was going to send chocolate, but oops! they looked yummy so I ate them. Consider that a public service to your waistline :)

    8
  9. […]   Recent Love,最近留言插件。 comment […]

    9
  10. […] To feed my obsession with comments (lord knows why, since hardly any of you buggers do it!), I have also added the Recent Love plugin, which lists recent comments on the sidebar over on the right, and the Comments Preview and Subscribe to Comments plugins. […]

    10
  11. I have this installed, but I’d like to see the links go directly to the actual comments instead of the post ID. Is there any way of tweaking the code to make this happen?

    11
  12. Ron,

    I actually found a fix for this, by adding (#respond) to the permalink in the code. This makes the link not only go to the post, but it scrolls down to the comments box, near where the last comment was placed.

    Is this OK to tweak?

    BTW: I love this plugin, because it omits by own comments, as I often reply to my readers this way. That’s why I prefer this plugin, but since I already have recent posts list above that, it seemed senseless for me to display more link direct to the same posts.

    Thanks!

    –Shane

    12
  13. Ron [author of post] said:

    thanks shane, i’ll add that feature in the next release. the only complication might be that different themes can use different names for their response section anchors (e.g., you use “#respond” but i’m using “#comments”), but this can be configured in the code.

    i’ll also add an option to go directly to the comment that triggered the entry in the recent-love list.

    thanks!

    13
  14. Michael said:

    Hi, fantastic plugin and love using it.

    Is there anyway to display the time/date of when the comment was published?

    Many thanks for your help, and keep up the great work.

    14
  15. Ron [author of post] said:

    thanks; glad you like it!

    a comment timestamp shouldn’t be hard; i’ll add it in a future version.

    (the hardest part will probably be making the date/time format easily configurable.)

    15
  16. federico said:

    hello. i use WordPress 1.5

    i want to see the “intial text of the comment” + “title of post”

    titel of post is possible. ok.

    but “intial text of the comment” ? it is possible?

    16
  17. Hello Ron,

    after long searches I stumbled across your sweet and simple plugin, which I am using now. Thanks for rolling it up :)

    Andreas of Nonformality

    17
  18. I’m adding the code in my sidebar and it still isn’t working, it’s just showing the code. What’s wrong.

    18
  19. […] Recent Love — The Recent Comments on my sidebar are powered by this simple plug-in that shows the titles of entries that have recently received comments. Has several nice options. […]

    19
  20. Hi Ron!

    Just wanted to drop you a line to say that your plugin is great; I’ve always used it on my blog.

    I’ve edited your source code a bit – primarily to change the formatting, but I added a feature –

    I’ve appended “#comment-XXX” to the URL your plugin generates so that the clicked link goes right to the published comment.

    See it in action at http://www.thedailyblitz.org

    Maybe something worth including in a future release? It was quite easy to implement.

    20
  21. Ron [author of post] said:

    hi andy,

    i love it! i’ll include it in the next release, as a configurable option.

    21
  22. […] Recent Love […]

    22
  23. Rodney said:

    What I want to do on my blog, is every few hours take the oldest post and move it to the
    front of the queue, all automatically. Anyone know if there is a plugin that can do this or
    a simple way to set up another plugin to do this (use my own feed perhaps)?
    Thanks.

    23
  24. Great plugin. Because I don’t want people to be posting in order to get links to their sites, I removed the website field from the comment form. What happens though is that in the list of comments generated by Recent Love the commenter’s name is hyperlinked to http:/// . Is there any way to have the name not appear as a hyperlink?

    24
  25. Ron [author of post] said:

    bodhi,

    i’ve just updated the plugin to include an option that does what you’re asking: it suppresses hyperlinking to commenters’ websites. please check out version 0.5 and let me know if that does the trick for you.

    also, shame on you for not wanting to link to your commenters’ websites. [-x i see that you entered your website url when you left the above comment, and i happily link to it in return for your taking the time to contribute to my blog. :) (if you’re concerned about spammers, i’d suggest akismet or spamkarma.)

    25
  26. Bodhi said:

    Hi Ron,

    Thanks for the very quick response. The reason I posted my website address was practical — so that in case I wasn’t being clear you could take a look at what I was talking about. I absolutely don’t need to seek out more Google juice! I wasn’t aware that akismet (which I already use) would do anything about people posting spammy links in the website field of the comments form.

    All the best,
    Bodhipaksa

    26
  27. Bodhi said:

    Works perfectly! Thanks again.

    27
  28. Ron [author of post] said:

    cool, glad it works for you. (and i’m happy that you find the plugin useful!)

    no worries about including your site in your initial comment–it made sense that you did. (but who couldn’t use a little more google juice? i know i could! :) )

    and i’m pretty sure (but not 100% certain) that akismet does look at the commenter’s url when deciding whether a comment is spam.

    happy blogging!
    ron

    28
  29. […] Recent Love by Ron Rothman This plugin is one of the first I installed, and is officially the only one that has survived the years gone by. In that time I’ve ultra-modified it (for example, mine will dynamically expand to include 5-10 posts from the last 2 days, and has a host of custom messages). Perhaps I will release it myself as a new version (with Ron’s permission of course)… Or perhaps I’ll just keep modifying it privately ;) […]

    29
  30. mark said:

    Hello
    Would you mind looking at http://www.turksheadfc.com
    I’m just building my site and I have installed your plugin and activated and entered the following code into the sidebar:

    However, no comments are being listed.
    Any suggestions as to why it isn’t working for me?

    Thanks
    Mark

    30
  31. […] Recent Love by Ron Rothman This plugin is one of the first I installed, and is officially the only one that has survived the years gone by. In that time I’ve ultra-modified it (for example, mine will dynamically expand to include 5-10 posts from the last 2 days, and has a host of custom messages). Perhaps I will release it myself as a new version (with Ron’s permission of course)… Or perhaps I’ll just keep modifying it privately ;) […]

    31
  32. […] Visit […]

    32
  33. Ron,

    Is there a way to at most show only one comment from any individual commentator? I don’t want to give people incentive to comment on multiple posts just so their names, and no one else’s, appear in the recent comments list.

    Thanks for the help!

    33
  34. Ron [author of post] said:

    jeremy, i’ll have to think about whether there’s an efficient way to do that. (i.e., a way that doesn’t involve many DB queries.)

    i’ll look at it for the next release.

    thanks for the idea!

    34
  35. thanks so much for the plugin. been looking for it for quite sometime :)

    35
  36. I am totally lost about this. It kinda works but i cannot really get the comments to show up nice as i like it. It’s in an accordian menu, the 2nd on the sidebar, i think there is an li in there but i don’t know how to get that out with $before and $after. Any help please

    36
  37. Ron [author of post] said:

    mannie, i took a look at your site, but i don’t see the plugin in your side bar. perhaps you removed it?

    37
  38. Yes, sorry, but i found another one that did work right instead

    [Ed. Note: Mannie, if you followed the instructions posted here, everything should have worked as expected; hundreds of people have successfully installed and used the plug-in. Naturally, it’s possible that there’s a bug, but I can’t help track it down without more information from you. Thanks.]

    38
  39. Edward said:

    @Ron,

    This’s great plugin and i use it, but unfortunately, this plugin doesn’t support the comment date :( so can you adding that feature?

    Thanks

    39
  40. Ron [author of post] said:

    edward, thanks for the suggestion. i like it, but it raises a few questions that would have to be worked out first, mostly around presentation: where should the date be displayed, and in what format? perhaps a template approach will work best.

    if enough people request this feature, i’ll add it to the next release.

    thanks!

    40
  41. […] Recent Love – A List of Recent Comments – zeigt aktuelle Kommentare an […]

    41
  42. […] Donate to this plugin […]

    42
  43. I love this plugin. Is there any chance it will be widgetized any time soon?

    43
  44. Hi Ron — Have been using the plugin for ages now, and I still love it. It’s been one of the very few flawless things on my blog ;)

    I’m glad to be one of your “see it live” examples. I appreciate the linkage, and I’m glad to serve as an example of your work, but unfortunately my web address is changing so to avoid a dead link in your post just switch the .com to a .net ;)

    Cheers and thanks again for your effort in making such a useful little tool.

    44
  45. Is it possible to show one comment per post on the index.php, archive.php, tag.php in a similiar style to gawker.com?

    (NOT in list form)

    45
  46. This looks neat, as I’m seeking a plugin that omits trackbacks. Can this be used with WP 2.6.2?

    46
  47. Ron [author of post] said:

    Ari, it should, but I haven’t tried yet. I’ve tested it on 2.6.1 and it works perfectly.

    If you try it on 2.6.2, please let us know what you find. Thanks!

    47
  48. Your plugin works fine in WordPress 2.6.3, but the accents doesn´t show in a Spanish website…

    http://www.webxprs.com/blog

    48
  49. hi Ron,

    love this plugin. I’ve enabled it on my own blog, but having trouble disabling comments from myself.


    $exclude_authors_comments = true;
    $identify_authors_by = 'comment_author_email';
    $excludes_sql_list = "('email1@gmail.com', 'email2@gmail.com')";

    I think that’s all the relevant code bits… but my comments still keep appearing. I’m using WP 2.7, so I was wondering if that might be why…. seems like you may not have tested on that version yet. Anyway, my next step was to check the database to see if any funny chars were getting into the email addresses. Oh yes, and I did try the other method of excluding comment authors – with just the name, but that didn’t seem to help either.

    Any debugging tips much appreciated!

    Thanks,
    writebrained

    49
  50. Ron [author of post] said:

    Hi writebrained,

    I’ve sent you another email to try and diagnose the problem. Let me know if you need more help and I’ll be happy to try–though I’m thinking that maybe you’ve fixed it, since your sidebar looks like it has a Recent Comments box which is working properly.

    And I just tested the plugin on WP 2.7, so I can now claim that Recent Love is officially compatible with it. :)

    50
  51. wordpress插件列表 @ 松哥的笔记 tracked back:

    […] Recent Love – A List of Recent Comments […]

    51
  52. Soph said:

    Is it possible to make the commenters names link to their profile instead of their website? Trying to make a small “community” where ppl write a little abt themselves and it would be super cool if their name in this plugin linked to their profile…

    Hope you can help :)

    52
  53. Hello I try many plugins to show recent commnets, I like this more than others the only problem is that I want to show not only the title of the post, but actually part of the text of the commenter comment… there is a way I can add that? or is to dificult to doit?
    thanks for the help

    53
  54. putradanindah said:

    i love this plugin, thanks

    54
  55. Andy said:

    Thanks for the plugin, it was just want I needed!!

    55
  56. Thank you so much, your plugin is exactly what I was looking for, it works a treat :)

    Peace!

    56
  57. I have enabled comments on all pages. The plugin, however, only retrieves comments for posts, not for media or pages. How can I enable posts for media (images etc) to be shown as well?

    57
  58. Hello

    thanks for the plugin. What I am trying to do is to “exclude” the comments of a specific post, from showing up in the RECENT comments list!! Any help would be appreciated!!!

    cheers!

    Jason

    58
  59. Jay said:

    Hi Ron,

    Thanks for a great plugin. Is there a way to add a short snippet of the comment, like say 20 words. If so, how should I do it.

    Thanks again.

    59
  60. Dhruv said:

    Hey Ron, it’s a nice plugin but can’t you make options available in the admin panel? Changing the configuration parameters in plugin file is very annoying. A clean admin interface will be appreciated.

    60

Leave a Reply

Comment formatting tips are available.


Your comment will appear on the site once it's approved. (Please read the COMMENT POLICY before posting.)