Recent Comments

Caveat

Unfortunately, due to ill-health, this plugin has not been developed or supported properly for some years. It works with the latest versions of WordPress (including on this website) but could possibly conflict with any WordPress features added after 2008 — e.g. custom post types — if you use them.

Purpose

This plugin displays a list of the most recent comments to your blog in a highly customisable way.

This is version 2.6.2.1 download latest version. It is compatible with WordPress 1.5–2.6.2.

Please note the new upgrade instructions!

  • 2.6.2.1 allows output to be restricted to one comment per post.
  • 2.6.2.0 supplies a .pot file making internationalisation possible; introduces the {imagealt} output tag and allows {excerpt} to output whole sentences; the content filter and the widget can now take a parameter string; output can be automatically placed after post content without editing theme files.
  • 2.6.1.0 allows the current post to be marked manually where the automatic mechanism fails; when used as a widget the plugin now honours the setting to show nothing when there is no output; and {commenterlink} now applies the appropriate WordPress filter.
  • 2.6.0.1 fixes the option to include attachments and adds a parameter to the {imagesrc} output tag to append a suffix to the image name.
  • 2.5.0.11 has a new option to include posts which are attachments; a new output template tag {authorurl} which points to the archive of the author’s posts; new behaviour for the {php} output tag which can now accept other output tags in the code.
  • 2.5.0.10 fixes several bugs.
  • 2.5.0.9 adds an option to match the current post’s author and extends the options for snippet and excerpt output tags to make the ‘more’ text into a link.
  • 2.5.0.8 adds an option to show posts by status, i.e., published/private/draft/future, changes the {categorynames} and {categorylinks} output tags by applying the ‘single_cat_name’ filter, and fixes a bug in WordPress pre-2.2 that stopped installation code running on Windows servers.
  • 2.5.0.1 has a new option to only show comments from the current post and improvements to the output tags {commentsnippet} and {commentexcerpt}.
  • 2.5.0 introduces a new output tag {imagesrc}, and adds more parameters to {image}. Fixes bugs with empty categories, excluded posts, and the option to omit current posts.
  • 2.5b25 makes some important changes: the {image} output tag now serves real thumbnails (couple of bug fixes too); output can now be sorted as you choose with sub-headings included; the {date:raw} tag modifier has been added to help the sorting; the ‘trim_before’ option has been replaced with the more logical ‘divider’.
  • 2.5b24 fixes to stop recursive replacement by content filter, {gravatar} to allow for ‘identicon’ etc., to {commenter} to allow trimming, and to remove a warning in safe mode
  • 2.5b23 brings a new option to filter on custom fields and adds proper nesting of braces in {if}.
  • 2.5b22 fixes bugs in several output tags, and introduces two new options: to show only pages and to omit comments by registered users.
  • 2.5b18 fixes a filtering problem and introduces the conditional tag, {if:condition:yes:no}.
  • 2.5b16 fixes a problem with {php}.
  • 2.5b15 more bug fixes and added ‘included posts’ setting.
  • 2.5b14 continuing bug fixes.
  • 2.5b11 has new features and improvements.
  • 2.3.6 restores the widgetiness I managed to remove in 2.3.5!
  • 2.3.5 has been rebuilt to save memory and can match the current post’s tags. It also fixes a bug with categories in WordPress < 2.3.
  • 2.3.4 can be used as a WordPress widget. Also can include or exclude the current post from the output.
  • 2.3.3 beta adds the ability to include as well as exclude categories and authors and is able to find posts by tag.
  • 2.3.2 beta fixes a conflict between tags and categories and grouping bug introduced in 2.3.0.
  • 2.3.1 fixes a stupid bug in category exclusion
  • 2.3.0 is compatible with WP 2.3
  • 2.1.1 fixes a bug when recent_comments() is used more than once on a page

The plugin has an settings page which lets you change how the output is generated and displayed.

Installation Instructions

  1. If upgrading from a previous version, first deactivate the plugin via the Plugins page and delete the plugin folder from your server.
  2. Upload the plugin folder to your /wp-content/plugins/ directory. You will also need to install the Post-Plugin Library.
  3. Go to your admin Plugins page and activate Recent Comments.
  4. Put<!--?php recent_comments(); ?--> at the place in your theme files where you want the list of similar posts to appear. Lorelle on WordPress has a good guide to modifying themes for plugins. If you are using a widget-ready theme the plugin can be placed from the widget admin page.
  5. Use the admin Options|Recent Comments page to set all the available options. Alternatively, the options can be overridden by passing a parameter to the recent_comments template tag.

Usage and Options

The configuration page will help you to set up the plugin to your satisfaction.

If you also install the latest version of Plugin Output Cache the output of this plugin will be automatically cached for efficiency.

168 replies on “Recent Comments”

  1. Hmmm, my previous reply has been rejected somewhere I think..

    My question was how can the plugin (widget) be used to also display comments on future posts. That does sound strange, but I’ve made a site for a festival, and all events (which are regular – and published – posts but with future dates, the date of the actual event) are published immediately by the use of a wordpress plugin (called ‘the future is now’).

    People are leaving replies to upcoming events, but the widget doesn’t show them.

  2. Richard: Sorry but that’s outside the range of Recent Comments. It might be a good idea for me to whip up a plugin that will though. I’ll put it on the ‘to do’ list but don’t hold your breath!

  3. jack: Have you tried setting Recent Comments to show future posts? I’m not sure it will do what you want but it would be good to check first. Let me know either way.

    It may be possible to see how the plugin you mention works and make some tweaks to Recent Comments if needed, but first things first.

  4. I have 2 recent comments for a post, but the recent comments plug in is showing it twice.

    I have also submitted this as a bug report.
    thanks in advance,
    Sue

  5. Hello Rob,

    Thanks a lot for your nice plugin!
    Is there a way to show a title of the post with the recent comment in the \”Recent Comments\”-list just once? Even if all last recent comments are made at just one article?

    Basically I created a list which shows the title and excerpt of the posts with the latest comments, but if people just commenting on one particular article the list looks like there is something wrong, coz the content is there several times.

    Thanks for your help
    Alfons

  6. Alfons: If I understand you correctly you should be able to set up the post title (etc.) in the group output template and keep the comment details in the output template — and group the output by post.

  7. Hi, thanks a lot this plugin. Its gonna help to buld up mu site\’s users profile pages.

    Just one question! Where should I put the condition ‘is_single()’?

  8. Rashed: The ‘is_single()’ condition is used with the plugin widget to get the widget to only show on single post pages. I am not sure how you are trying to use the widget on user profile pages.

  9. I am using the plugin and not the widget since i wanted to display them in a box and i was able to achieve it using divs in the stylesheet. However i want this to be shown only on the home page. I tried adding tag..but only after the

    tag.

    So the format is:

    I am still trying to learn wordpress so any help here will be appreciated. 🙁

  10. ohh..i think the php codes are not supported…i used the is_home tag before adding the recent_comments tag 🙂

  11. Thanks..got it right now :).One final question..is it possible to style the box if i use widget instead of plugin…or can u tell me how can i display a title (something like Recent Comments) if i use the plugin? I tried it in the placement page under Output after post parameter but its not displaying

  12. Arshad: There are two ways to display a title if you use the plugin: you can stick a title in the HTML before the plugin call or you can include a title in the prefix codes (from the output submenu).

  13. I\’m using the plugin on my site and I was wondering if there is a way to only show the most recent comment per post rather than all in a series.

    Say I have 10 comments and 4 of them are on the same post. The way it currently works, it shows them in a time based list or grouped together by post. What I want is only the latest comment per post to show up since the other 3 only pollute the recent comment area.

    I saw another plugin that \”capped\” per post how many posts were allowed to show up in the most recent widget. Can this be accomplished as is or is this an upgrade needed to be added to the current plugin?

    Basically this would return a forum style listing.

  14. Robert: Recent Comments can’t do that at the moment but so many people request it that I really ought to take another look. It’s would be a messy addition to the code of Recent Comments and might require a plugin all of its own. Let me think…

  15. Robert: Sometimes things are surprisingly easy! The next release of Recent Comments (later today if I can manage it) includes the option to restrict the output to one comment per post.

  16. Rob, thanks for the quick update, I do appreciate it. The unique feature works great and is exactly what I was looking for. However, it seems to pick the first comment per post as the display and not the last (most recent). Is this a sorting issue I can fix within the current structure or is it tied to the unique call in the plugin itself?

  17. Rob, as additional information on that last issue. It appears that the {commenter} is affected as the {commentdate} and {commenttime} are both correct for the most recent comment. So {commenter} appears to be pulling the name of the first comment per post and not the most recent. Hope that helps.

  18. Robert: I should have known it couldn’t be as easy as that! After a morning of fiddling about I think I have it right and I am sending you an update by email to check out.

  19. Hi Rob,
    I have a question about placing a second recent_comments list in the sidebar. I have made a list for one category so tha people only see the comments on that category. Now I want to place a “normal” comments list in te sidebar that shows all the comments on the homepage and other pages/cat excluding the comments from the category from the first list (am I clear :):)
    I have placed this in a php widget <?php if (function_exists('recent_comments')) recent_comments(limit=9&match_cat=false&excluded_cats=16&included_cats=10,15,1,14,4,3,8); ?> But for some reason the list is not showing. Is there something I have done wrong here in the code? It needs to override the option settings.

  20. Printer: Could it be as simple as the fact that the parameter to recent_comments should be in quotes? The mistake may just be an artefact of posting the comment so let me know.

  21. Two questions — one on filtering and the other on sorting.

    1. Is there a way to display recent comments only after they’ve met specific conditionals? I’d like to display the first line of a comment only if that comment starts with a specific term. e.g. if I specify the term to be “time” then the comment has “time 3:47” in first line of the comment then it would allow “3:47” to be displayed.

    2. I’m trying to create a scoreboard, so I’m interested in being able to sort the list in both ascending and descending order. Anyone know how I might tackle this?

  22. Dan: There’s a new feature in the next release which allows the output to be filtered according to content so you would be able to select only the ‘time’ comments. The {php} output tag might help you select the parts of the comment you need.

    If you wanted to then sort on the time you could conceivably do it — there is the option to sort by an output template tag.

    All that said I suspect you would be better with a custom solution that better targets your specific aims.

  23. Hey, thank for this great plugin!

    I have a question, too:
    Is it possible that the plugin displays three points (“…”) after the [commentsnippet] if it’s longer than the whole comment?

  24. Hey Rob, will that change you sent Robert be in the next general release? I see that you’re using GROUP BY when you return only one record per post but MySQL (at least in v5.0) says this about the items from a group-by that aren’t part of the group-by.

    Do not use this feature if the columns you omit from the GROUP BY part are not constant in the group. The server is free to return any value from the group, so the results are indeterminate unless all values are the same.

    So not only might we see something like the wrong commenter (I’m having the same issue as Robert) but in theory the server MIGHT return values from DIFFERENT records, mixing commenter and comment!

  25. Ok, i have found out the ‘method’-paramater. But {commentsnippet:130:trim} does’t work for me for example. It doesn’t add an ‘…’ . What I’m doing wrong?

  26. Hi, I wanna thank you for your suite of plugins you have developed. They are all working great except for recent comments. I am getting an error in WordPress when I try to access the plugin’s configuration (Cannot load recent-comments.php.). The actual file “recent-comments.php” displays an error “Fatal error: Call to undefined function get_option() in /****/****/****/****/wp-content/plugins/recent-comments-plugin/recent-comments.php on line 175” and in “recent-comments-admin.php” displays an error “Fatal error: Call to undefined function add_action() in /****/****/****/****/wp-content/plugins/recent-comments-plugin/recent-comments-admin.php on line 9”. I was wondering if you knew what the issue I am having is.

    -Thanks

  27. Having some trouble here. 🙁

    I am using recent comments to dynamically build callouts in my posts to show the most recent comment for that particular post.

    It works but it never shows the most recent comment. Here’s the link:

    http://www.inlookout.com/2008/10/22/mormons-donations-account-for-77-of-all-money-raised-for-yes-on-prop-8/

    I want it to show the last comment posted. I’ve messed with the grouping but nothing ever changes it. It always shows the third comment received in this case.

    Any advice would be helpful.
    Thanks!

  28. Found a bug:

    If you allow anonymous comments (those where all fields are left blank), Recent Comments doesn’t correctly fill in “Anonymous” in place of nothing. As a result it breaks the display (grammatically) and you end up with “commented on” instead of “Anonymous commented on”.

    It sounds simple enough, I wonder if a fix would be possible?

  29. The unique feature works great and is exactly what I was looking for. However, it seems to pick the first comment per post as the display and not the last (most recent). Is this a sorting issue I can fix within the current structure or is it tied to the unique call in the plugin itself

  30. How can if filter out my own comments, when I am the original WP admin account?

    Excluding author doesn’t seem to work. When I selected exclude author “admin”, no comments were displayed, i.e. “none found”. I removed the admin exclusion and tried excluding a random other author on the list and the display was fine.

    From this, I’m assuming there’s something different about the way the original admin account is filtered?

    Thanks! (Your plugins are great!!!)

  31. I’ve also experienced the massive load problems that James described. Setting recent comments to display the last 5, only if they’ve been in the last 7 days and it hammers my server. The blog has more than 16,000 comments. Could that be the culprit? I have submitted a bug report, please feel free to contact me for more information.

  32. Hi,

    I am trying to create a new output_tag to return the value of a new filed I created above the comments text area. The new field’s variable is “recipe_name”. I tried to duplicate the otf_postid function and wrote this:

    function otf_recipe_name ($option_key, $result, $ext) {
    return $result->recipe_name;
    }

    But it didn’t work. Can someone help?

  33. Hello Rob,
    I am new with the WP architecture and I am trying to make some changes on an existing blog site. The site is using your Recent_Comment module which works perfectly.

    However, there are some new requirements and I am not sure if they are already built in to the current structure. I don’t want to reinvent the wheel if you know what I mean … 🙂

    Here are the new requirements:
    1. when someone goes to the Authors page, I need to display the posts and comments made by that Author only. The post part is simple, but I am not sure how I can use the existing recent_comments framework to pull the comments made by only that author. Is there any special parameter that I can pass into the recent_comment() function to make it happen?

    2. Is there any way to pull the recent comments with a dynamic/run-time date range settings so that the user can specify the date range?

    I understand that in order to make this happen the Where clause in the sql query needs to be changed, I wonder if there is a way to pass in the where clause in the run time?

    Thank you in advance for all your help.
    Arman

  34. Is there anyway you can make your plugin work with paged comments in 2.7? Everything else works perfectly in 2.7 except for that. I think it’s a new variable they introduced in 2.7 that adds a comment-page-# into the url.

    Thanks!

    Marina

Comments are closed.