WordPress Recent Comments Plugin / Widget

This plugin will add a list of the most recent comments posted to your blog. They are gathered in descending order (newest at the top), but then grouped by post title, so that comments from the same post are listed together. The list items will be links to the comments, and will contain the name of the commenter.

The following parameters are configurable by the user, either from the widget admin interface or directly (if used as a standalone plugin):

  • Number of comments to show: Total number of comments to display
  • Number of words per comment excerpt: The first N words of the comment will be listed
  • Max comments per post: This option is a “cap” to ensure that multiple posts are included in the list, even if all the recent comments were from a single post.
  • Max letters per word: This option is to deal with long “words” in the comments (specifically raw URLs) that can interfere with the formating of the list, depending on the CSS rules applied.

Download FreePress Recent Comments Widget

Installation:

  1. Extract all files in the archive into your plugins directory. The archive should contain a folder called “freepress”, which should be placed directly under the plugins directory, and all the files distributed with this plugin should be in the “freepress” folder. For example: /var/www/wordpress/wp-content/plugins/freepress/recentCommentsWidget.php
  2. If you are using the widgets plugin, the tagboard will automatically appear as an available widget for your sidebar.
  3. If you prefer to manually add the tagboard to your theme, you can insert the following code wherever you’d like the tagboard to show up:

    <?php
    if(function_exists('fp_get_recent_comments')) {
    echo fp_get_recent_comments(7, 5, 5, 0);
    }
    ?>

    The arguments are in the order described in the list above. In this example, it would show 7 comments total, 5 words from each comment as an excerpt, a maximum of 5 comments from any one post, and no limit on the number of characters per word in the excerpts.

*Note: This version of the plugin has been tested in WordPress 2.x as well as recent versions of WordPress MU. Please let me know by commenting here if you run into any issues.

This program is free software; you can redistribute it and/or modify it under the terms of the GNU General Public License as published by the Free Software Foundation, version 2.

This program is distributed in the hope that it will be useful, but WITHOUT ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License for more details.

98 Responses to WordPress Recent Comments Plugin / Widget

  1. matrixyang says:

    status: wordpress2.03

    I followed the steps above,but the recent comments are just not appeared.

    I try to add [echo "hello";] before [ fp_get_recent_comments(7, 5, 5, 0);],and the [echo "hello";] worked so the [function_exists('fp_get_recent_comments')] is
    true.I gussed there is no wrong in instalation steps 1 2 3.

    I didn’t know how to deal with this questios.Could you help me solve it?

    Fogive my poor English.
    Thanks.

  2. JB says:

    From looking at the site, I’m guessing that it has something to do with the different language characters, but I’m not sure. I know I’ve seen it (or the earlier version) used on non-english blogs, but I haven’t done any testing in that regard myself.

  3. Eskimojoe85 says:

    What is the file that we’re suppose to be downloading? I have no idea what a tar.gz file is.

    Looks really good on your site.

    Thanks

  4. Eskimojoe85 says:

    Never mind I got it.

    Thanks

  5. richard says:

    Your example should say: echo fp_get_recent_comments(7, 5, 5, 0);

    You are missing the echo! That’s why matrixyang can’t see anything. I like the plugin. Good work!

  6. JB says:

    Ah, good catch!

  7. Mark Wegner says:

    Hi,
    I like your plugin, but I’m interested in an expanded functionality.

    I’d like to have the post groups be listed in order from most recent posts to oldest posts, regardless of how recent comments.

    I’d also like to be able to have my users reply to comments listed on these pages, could you make a “reply to this comment” link that would send them to the post page and at the place to reply to a comment?

    These ideas would allow this plugin to be an interface for the comments in one location (such as running this plugin script on a page), instead of having to go to each page individually to read comments.

  8. JB says:

    The sort order is definitely something that could be adjusted, sorting by post date rather than comment date. I will consider that for a future upgrade.

    As for replying to a comment, right now clicking on any comment listed will take you to that comment, which (if it’s the most recent one) will be at the bottom of the list which usually has the comment form right there. This is assuming the user hasn’t altered the theme to one that does not conform to the “standards” of WP post pages with a comment form at the end.

  9. LA says:

    How good is it in handling lots of load? say around 700-1000 comms/day?

  10. JB says:

    Sorry for the slow response; I’ve been out of town until today. I don’t think I’ve actually tested it in that regard, but theoretically it should do just fine.

    It just runs one query on the comments table, and limits the results according to the parameters that you specify. So, for example, if you want to show the 7 most recent comments at a maximum of 3 comments per post, it will limit the query to retrieving the 21 most recent comments all in one query and then sort through them, so that query will never have a huge result set.

    I think the fact that the result set will always be fairly small and only run once per execution of the plugin should make it pretty quick. I imagine that the performance could degrade as you get a huge number of comments in that comments table, but that would be more of a MySQL issue at that point.

    I suspect that if there were any scalability issues, they would be caused by a high number of page loads (plugin executions), not necessarily the number of comments in the system. If performance did become an issue, I guess I could add some sort of caching which would only recalculate the list every X minutes or so, and draw it from the cache on all other requests. This would be fairly easy, but I don’t know whether it would necessarily be worthwhile.

  11. Todd says:

    I like this plugin, but the maximum comments per post isn’t working correctly.

    I want to have the last 5 comments but I only want 1 comment per entry, so this should show 5 different entries. The last entry folks commented on had about 8 entries on it in a row, so it only shows that one entry.

    If $no_comments is 5 and $max_comments_per_post is 1, shouldn’t this show me 5 different entries with a single comment from each one?

  12. Pingback: ПерекреÑ?ток миров :: ПерекреÑ?ток: Кубики и примочки

  13. fFreddy says:

    Could I trouble you with a problem ?
    A blog I visit, http://www.climateaudit.org , is using your plugin. When the first 7 words or so of a new comment contains a long string of text with no white space – usually, a long URL – the plugin is not able to wrap it around.
    On my Firefox, this is no problem – the URL stretches out of the right hand side of the Recent Comments box. If I scroll right, I can see it, but there is no reason for me to bother. Users of Safari and Opera also report no problem.
    The problem arises for Internet Explorer users (surprise, surprise). The right hand end of the URL aligns with the right hand edge of the Recent Comments box, and the LHS of the box is extended as far left as it needs. Unfortunately, this makes it impossible to read the rest of the blog.
    A screenshot of what this looks like is posted as a comment at http://www.climateaudit.org/?p=429#comment-40852 .
    The blog administrator hasn’t been able to fix this. Can you suggest anything that might solve this problem ?
    With many thanks.

  14. fFreddy says:

    Please ignore my last – we’ve just noticed the ‘Max letters per word’ parameter, which appears to have solved the problem.

  15. Pingback: Disruptive Library Technology Jester :: Modifications to FreePress Recent Comments Plugin

  16. LA says:

    I love the idea where you’d add a time parameter to the plugin. I mean, w/ pageloads of around 200k, that would seriously help the load on the server. @ the moment w/ the plugin executing almost every pageload, the load sometimes shoots up to around 90.

    Please do email if you have time & maybe we can work ssomething out?

    Thanks for the response above & awesome work on the plugin!

  17. JB says:

    Yes, I’ll plan to incorporate that into the next version, then – I just can’t promise when that will happen, as I will be pretty swamped with “real life” development work for the next month or so.

  18. LA says:

    no worries, JB!

    THanks for this nice piece of work & I’m looking forward to the upgrade!

  19. Dirk Olbertz says:

    I found a bug: instead of “ORDER BY comment_ID” it should be “ORDER BY comment_date” on line 225.

    I just imported my blog from MT to WP and so the order of comment_IDs did not match the order of comment_date.

    In general, it’s safer to only rely on the date and not on the id.

  20. JB says:

    Good point. I don’t know if I’ll change it, though, since the sort order will be consistent for everyone unless they are doing something special (like the import you mentioned).

    I guess you could go either way, but I would speculate that the potential advantage to using the comment ID instead of the comment date would be speed; I suspect that it’s faster for the database to sort by an integer column than a date column, especially when that integer column is the primary key for that table.

  21. Dirk Olbertz says:

    Sorting by ID is never a good idea, as the consistency never should be assured. Other databases and/or table models may fill up “gaps” on the primary key, etc..

  22. JB says:

    True, but not on this particular column in this particular table in WordPress, as far as I know. I’m no MySQL expert, but I’m pretty sure that an auto_increment column in MySQL will never go and back-fill missing numbers.

    Like I said before, it’s a good point; of course dates should be used when you’re aiming for strict chronological sorting (and accounting for possible variations like the import one you mentioned), but when all you need is sequential sorting, an automatically incremented integer ID is probably just fine.

  23. Pingback: TechZOnline.net » New plugins, Recent Comments, Plugins Used & Gravatar Signup

  24. TechZ says:

    I like this plugin, just done installing it, easy to use, even recommeneded it to some people. Just the one thing I’d like is to be able to get rid of that extra blank line after the post title, before the comments. It would also be useful to be able to set X number of Posts only for which comments would be displayed, like only for 3 posts should comments be displayed.

    Thanks again!

  25. JB says:

    Cool, glad you liked it.

    I’m not exactly sure what you mean by the extra line thing, but hopefully it could be solved by altering some CSS. If you want the comment list to start right after (on the same line as) the post title, you may have to set the CSS rules to display the post titles in the list (which are h4 elements) and possibly the list itself (ul) as “inline”, rather than “block”, which these types elements default to. If that’s not what you meant, let me know, and maybe I can help out in some way.

    The limit on the number of posts is a good suggestion. I’ll plan to incorporate that in the next version.

  26. TechZ says:

    Thanks for the reply JB, with some to the output code, mentioned on my post, I was able to get it to not leave a blank line after the Post title, that way saving an extra line. I look forward to having a choice of X max posts to display in the next version. :)

  27. aseed says:

    Ahhh i like it this plug!

  28. Pingback: Chia Hao Lo’s Blog » Blog Archive » Blog的設定

  29. Daus says:

    Good comments plugin

  30. LA says:

    Hey JB!

    It’s me again :-)). No luck on adding the time parameter to the plugin? Can’t we work something out on the side? Give me an email, my friend!!

    cheers

  31. JB says:

    I’ll try to get it done by this weekend; no promises, but I did say about a month, so I guess I better stick to that. :)

  32. LA says:

    haha

    you’re awesome, man. Let’s hope that solves probs for highload sites!!!

  33. LA says:

    Show me some love, JB!! hah

    (just checking in!!)

  34. Pingback: BloggingPro China » Blog Archive » WordPress Widget: Recent Comments Plugin / Widget

  35. Pingback: John’s blog » Blog Archive » I added the Recent Comments plugin to this blog

  36. Everton says:

    Hi

    Exactly what I was looking for, but I have 2 probs:

    - any idea why my comments are so spaced out in Firefox?
    - and why the post titles are so big in IE?

    Thanks

    EB

  37. JB says:

    I’m not seeing an issue in Firefox, but I suspect that the difference in size of the titles between IE and FF is probably due to the text size being specified in em’s and IE (or FF, but probably IE) not correctly applying a size at some point in the tree, since em sized are relative to the parent elements.

  38. Torley says:

    Thank you graciously for such a handy plugin! I’ve replaced the default WordPress widget with this and did some very minor tweaking to change the output style (“h4″ was leaving an extra line of blank space at the top of my widget box).

    I’m also curious, how did you do the show/hide widget things in your sidebar? They look really handy for hiding clutter!

    Thanx again!

  39. Pingback: Admin Drop Menus and Recent Comments Widget added « Torley Lives

  40. The screenshot for this plug-in looks awesome, but for some reason, after pasting the example into my WordPress sidebar and taking care to make sure that recentCommentsWidget.php is in the right directory, I still can’t get the plugin to display, no matter what browser is used to view the page. If I paste it straight in without any tweaking, I see the actual code. Yes, I’ve checked permissions; furthermore, other .php add-ons are working just fine. I’m using WordPress 2.0.4 on a 1and1.com server. Help. I’d badly like the use the plug-in. TIA for ideas! – David Rothman

  41. JB says:

    The sample code above has a space inserted in the opening PHP tag, but I think that’s because of a filter that WP includes when editing the post. Did you try with the corrected opening PHP tag?

  42. Alas, yes, I did try closing up the space in the opening PHP tag. I guess I’m rapidly reaching the point where I may just redo the site anyway with a widgetized approach. Thanks. David

  43. JB says:

    Hmm, sorry I can’t think of any other possible causes for why there wouldn’t be any output shown.

    Looking at your site this morning, it appears you’ve figured it out at this point. If you do decide to go with the widget approach, this plugin should work as a widget as well.

  44. Torley says:

    Hey JB! Nice to see you on here, did you have an answer perchance to my question above about how you do the awesome “show/hide” thing? Thanx. :D

  45. Maggie says:

    I tried opening the zip file, but I’m unable to. I’m just getting an error.

  46. JB says:

    It’s actually a gzipped tar file; maybe I should upload a zip archive as well to make it easier for people to get to.

  47. Maggie says:

    I would really appreciate it, because the name of the file has .tar.tar twice on the end of it right now and I think that is why I can’t unzip or download it.

    Thanks

  48. Torley says:

    JB, I noticed something else: if I type a really long word or an URL, it doesn’t wrap in the comment sidebar, and instead encroaches on the body of the page. For example: http://www.google.ca/search?num=100&hs=PY0&hl=en&safe=off&client=firefox-a&rls=org.mozilla%3Aen-US%3Aofficial&q=freepress+recent+comments&btnG=Search&meta=

  49. Torley says:

    Pardon for the mess, I should’ve included that URL at the beginning of the comment so it showed up. Easy enough to test though, I’m curious to know if it happens here too! :)

  50. JB says:

    No problem, Ive seen that before.

    The fix is to add a CSS rule that hides anything that overflows the recent comments container; like so:


    div.recentcommentscontainer {
    overflow: hidden;
    }

  51. Torley says:

    Aha! Great idea, than a lot, JB.

    Also — I found out the “Max comments per word” setting can help. Good to know.

  52. Maggie says:

    Hi JB, Thought I’d try again. When I try to unzip your file I get the following WinZip error…”Error reading header after processing 0 entries.”

  53. Maggie says:

    Hi JB, I finally got it and I really love the plugin. One question though, the text size of the titles is way too bold and large. How would I change this?

  54. Alexander says:

    Thanks for this plugin

  55. nepf says:

    Thank you!

    I whould like to put some CSS-rules in my style.css – but I need some help.

    Do you have the syntax for an example?

  56. JB says:

    Sure; if you see any reference sites that you like the look of you can always view the CSS for those.

    Here is what I use for how it looks on my site:
    li.widget_fp_recentcomments div.recentcommentscontainer {
    display: block;
    color: #191736;
    background-color: #FFF0BD;
    border: #191736 1px dashed;
    overflow: hidden;
    padding: 0px 5px !important;
    }

    li.widget_fp_recentcomments h2.widgettitle {
    font-size: 1.6em !important;
    font-weight: bold;
    font-family: georgia, times new roman,serif;
    color: white;
    margin: 0px 0px 5px 0px;
    }

    li.widget_fp_recentcomments div.recentcommentscontainer h4.recentCommentsPostTitle {
    margin: 2px 0px 2px 0px;
    color: #191736;
    font-size: 1em;
    font-weight: bold;
    }

    li.widget_fp_recentcomments div.recentcommentscontainer h4 a:hover { color:#191736 !important; }

    li.widget_fp_recentcomments div.recentcommentscontainer ul {
    display: block;
    margin: 0px 0px 5px 0px !important;
    padding: 0px 0px 5px 0px !important;
    color: #191736;
    font-size: .85em !important;
    text-decoration: none;
    font-weight: normal !important;
    border-bottom: #AFA37C 1px dashed;
    }

    li.widget_fp_recentcomments div.recentcommentscontainer ul li {
    margin: 2px 0px;
    }

    li.widget_fp_recentcomments div.recentcommentscontainer ul li span.commentAuthor{
    font-weight: bold;
    }

    li.widget_fp_recentcomments div.recentcommentscontainer ul li a:hover {
    color: #191736 !important;
    font-weight: normal !important;
    }

  57. Pingback: Easy Webbers » WordPress Plugin: Recent Comments

  58. Pingback: some Wordpress SEO on the default settings · abnuno

  59. Is there any way to exclude pingbacks from the list of recent comments displayed?

  60. kinos says:

    can`t work in wordpress2.1

  61. Adult Personals says:

    I love this plugin. But would like to have the updated version for wordpress2.1

  62. Pingback: La strada in salita » Ultimi commenti

  63. KA says:

    Love this but is not working in WP2.1. Any possibility of an update?

    KA

  64. JB says:

    When was the last time you downloaded it? I did recently publish an update, and it’s running on this blog, which is WP 2.1.

  65. J.D. Hollis says:

    Is the link above broken for anyone else?

  66. JB says:

    Oops, should be working now.

  67. Dario says:

    No the file is corrupted.

  68. JB says:

    No, it’s good. Are you maybe trying to open it as a .zip file rather than .tar.gz?

    Perhaps I should just post it in .zip format to make it easier for more people…

  69. Pingback: idiolect » Blog Archive » Useful Wordpress plugins

  70. Ved says:

    nice blog. i will certainly book mark it. i also have a web site.
    it is

    http://nbbhost.uni.cc

    Regards

  71. Julie says:

    Hi -
    Would it be possible to post this as a zip file as you tentatively suggested above?? It is exactly what I’ve been looking for, but I’m afraid I’m not making any headway trying to figure out how to extract files from a .tar.gz ….

    Thanks!!!! – julie

  72. Pingback: WordPress-Plugins » Das Gedankenhabitat

  73. Pingback: Sunaryo Hadi | TypoXP 2.0

  74. Pingback: Wordpress Recent Comments Plugin / Widget | Voluntary Death

  75. Pingback: HTMLHelp.blog : The HTMLHelp.blog Theme and Plugin Page

  76. stroz says:

    not working for me….when i download it all i get is the php file for the widget no other files as suggested by the instructions….is there a link to download the plugin or just the widget???

  77. JB says:

    The .php file is the only file you need. If you’re using the widgets plugin already (by Automattic) then this plugin should be available in your list of widgets after you activate it.

    If you aren’t using the widgets plugin, see the directions above for using it on its own.

  78. stroz says:

    I’m trying to use it on its own…I’ve activated the pluggin and pasted this code in my sidebar:

    but that code is all that shows up…must be missing something

  79. blackxmas says:

    pluggin doesn’t work…just shows code..i’ve enabled the plugin and added the required code and all it shows is that code…what is the problem?????????????????????????????/

  80. JB says:

    Make sure that the opening PHP tag does not contain a space between the < and the ? as was shown in the example. That was an error in the original post.

  81. Pingback: WP Plugins DB » Blog Archive » Recent Comments Grouped By Post Widget / Plugin

  82. Pingback: Munawar.Info » Redesign Theme Munawar.Info

  83. Pingback: digiboy: Post : Sidebar widgétisés, mon Capitaine!

  84. CMP2 says:

    Thanx for this plugin;)

  85. Pingback: Love Your Commentors And Be Rewarded | Web 2.0 How-To Spot-er

  86. vihali says:

    How can I display comment author’s name with the link to their website, not just plain text?

  87. JB says:

    Right now it will only show links for registered users, not anonymous commenters.

    I plan to release a new version shortly that does offer that option, but I’d caution against using it due to the potential for abuse.

  88. Pingback: SNAFU » Freepress Recent Comments (plugin)

  89. Pingback: 12 sever?na plugins, tutorials och hacks till Wordpress | Webbrelaterat

  90. Pingback: 10 Tips to Get More Comment In Wordpress | Themeflash

  91. Pingback: Francesco Iovine » Blog Archive » Pimping my blog(s)

  92. Pingback: www.html-kod.com|wordpress yorum eklentileri,wordpress comments plugin,wordpress 10 yorum eklentisi,yorum eklentileri |

  93. Pingback: 45 Ways to Power Up Your Blog - One Man's Blog

  94. Pingback: Widgets: Pimp your blog