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. wordpress插件列表 @ 松哥的笔记 tracked back:

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

    1
  2. 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 :)

    2
  3. 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

    3
  4. putradanindah said:

    i love this plugin, thanks

    4
  5. Andy said:

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

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

    Peace!

    6
  7. 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?

    7
  8. 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

    8
  9. 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.

    9
  10. 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.

    10

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.)