Simple-Recent-Comments WordPress Plugin

This is the homepage of the Simple-Recent-Comments plugin for WordPress which provides a template tag that displays a list of the last comments posted on your blog.

This is yet another recent comments plugin. I tried to keep the display of the recent comments as simple as possible.

Features

This plugin displays a list of the most recent comments. Each list item contains two things:

  1. The comment author. This is also the hyperlink to the actual comment. The title of the relevant post is displayed in this link’s tooltip, so to keep the display as simple as possible.
  2. A small excerpt of the comment.

Usage

This plugin returns a list of the most recent comments on any post of your blog. It provides a template tag (function) you can use:

<?php src_simple_recent_comments(arg1, arg2, 'arg3', 'arg4') ?>

Arguments explanation:

  • arg1 (numeric): The number of comments to return. Default: 7
  • arg2 (numeric): The comment excerpt length. Default: 60. This number also includes the HTML tags. Only this number of characters are retrieved from the database in order to reduce the load.
  • arg3 (alphanumeric): The HTML code to prepend to the list. Default: <li><h2>Recent Comments</h2>
  • arg4 (alphanumeric): The HTML code to append to the list. Default: </li>

The default values are based on the assumption that this template tag is placed in the sidebar. You can customize it as you like.

It can be used without arguments. In this case the defaults will be used.

<?php src_simple_recent_comments(); ?>

I would recommend to use the following way of placing the function in your template:

<?php if (function_exists('src_simple_recent_comments')) { src_simple_recent_comments(); } ?>

This way, even if you de-activate the plugin in your administration panel, but you
have not removed it from your templates, it would not produce any errors.

Installation

Copy the simple_recent_comments.php file in your /wp-content/plugins/ directory and activate the plugin from the administration panel.

Place the template tag in your sidebar.

Compatibility

It should work will all versions of WordPress. Anyway, you can try it.

License

This project is released under the terms of the GNU General Public License version 2 or later.

Downloads, Issue Tracking, Support

For the latest releases of Simple-Recent-Comments please visit the Simple-Recent-Comments development web site.

This plugin is not available on the WordPress Plugin Repository.

This project is no longer supported. Submitting support requests, issue reports or feature requests is not possible at this time.

Notes for theme designers

It is widely known that WordPress lacks a function that returns a list of the recent comments. Simple-Recent-Comments fills this gap in a simple and clean way. This plugin was created with both end users and theme designers in mind.

End users can install the provided plugin as described above.

Theme designers may integrate the plugin into their themes. For easier maintenance, I recommend that theme authors follow these simple instructions in order to integrate the plugin:

1 – Put the simple-recent-comments.php file into the theme directory.
2 – Insert the following line into one template of your theme. It doesn’t matter in which one you insert it, as long as it is inserted before the src_simple_recent_comments() function is called.

<?php include (TEMPLATEPATH . '/simple_recent_comments.php'); ?>

3 – Display the recent comments list by calling the src_simple_recent_comments() function as described in the Usage section of this document:

<?php src_simple_recent_comments(); ?>

It is as simple as that.

Changelog

* Wed Oct 04 2006 – v0.1.2
– Plugin information update
* Sun Apr 30 2006 – v0.1.1
– Now works with non standard wordpress table names.
* Sat Jan 14 2006
– Initial v0.1 release

Development Status

The functionality implemented by this plugin should be considered outdated and not tested with recent releases of WordPress.

Simple-Recent-Comments WordPress Plugin by George Notaras is licensed under a Creative Commons Attribution-NonCommercial-ShareAlike 4.0 International License.
Copyright © 2006 - Some Rights Reserved

George Notaras avatar

About George Notaras

George Notaras is the editor of the G-Loaded Journal, a technical blog about Free and Open-Source Software. George, among other things, is an enthusiast self-taught GNU/Linux system administrator. He has created this web site to share the IT knowledge and experience he has gained over the years with other people. George primarily uses CentOS and Fedora. He has also developed some open-source software projects in his spare time.

33 responses on “Simple-Recent-Comments WordPress Plugin

  1. Robin Permalink →

    Thanks for the plug in! It was really easy to install and use!

  2. Christiaan Permalink →

    Stubbornly refused to show up on my plugins admin page.

  3. George Notaras Post authorPermalink →

    Maybe, this is a permission problem. Is the plugin php file readable by the web server or world-readable?

  4. George Notaras Post authorPermalink →

    Cheers dude! :-)
    Why don’t you make the widget publicly available, so I can add a link in the plugin’s page above?

  5. Mika Perälä Permalink →

    Nice little script! I made it a widget, so you can use it with the widget-plugin in WordPress 2.0.

    Send me an email if you like to have it :) Cheers and thanks for the good work!

  6. George Notaras Post authorPermalink →

    I guess I responded without noticing your last comment. I ‘m glad you sorted things out :-D

  7. Dave Permalink →

    Hi there

    I have a problem with this plug-in, and I really don’t understand what the hell is going on! I have installed it at my blog, and it shows up fine, only the comments displayed are the most recent comments from my old blog, which is held on the same server. The plug-in PHP file is installed in the correct place for the correct blog.

    Any idea on what on earth is happening?

    Thanks

    Dave

  8. Dave Permalink →

    All sorted. The plug-in directly references the database tables using the wp_ prefix. I run several blogs from one DB, and so my prefix for the blog I wanted the comments to appear on was different. An edit to the plug-in file soon sorted it.

  9. George Notaras Post authorPermalink →

    Hello Dave,
    You probably keep the old and new wordpress tables in the same database and the new ones have a prefix different than wp_. This is not a problem. All you need to do is the following:

    Open the plugin file in a text editor and replace all occurencies of the following (there are only a couple):
    wp_comments
    wp_posts

    Replace them with the respective table names of your new blog and things should be set then.

    Unfortunately, I do not have the time to investigate this more, but I believe the above will resolve the issue.

  10. Dave Permalink →

    Yep, thanks George – I was really freaked out for a couple of hours

    Now it’s working, I can comfortable say that it’s a great plug-in! Good work!

    Dave

  11. Helge Permalink →

    I get the following error when using your plugin:

    SELECT DISTINCT ID, post_title, post_password, comment_ID, comment_post_ID, comment_author, comment_date_gmt, comment_approved, comment_type, SUBSTRING(comment_content,1,60) AS com_excerpt FROM wp_comments LEFT OUTER JOIN wp_posts ON (wp_comments.comment_post_ID = wp_posts.ID) WHERE comment_approved = '1' AND comment_type = '' AND post_password = '' ORDER BY comment_date_gmt DESC LIMIT 7
    
  12. Dave Permalink →

    I am trying to get this to work now with a different site that uses div tags rather than lists to set up the sidebar. Specifically:

    div class=”box_top” is used for the header, the bit in h2 tags

    div class=”box” is where the list for the individual list items go.

    div class=”box_bottom” closes the list item.

    I have tried changing and adding bits to the plug-in php but all I get are errors. Can you help please?

    Many thanks

    Dave

  13. George Notaras Post authorPermalink →

    Helge: Probably your blog’s database tables are not prefixed with wp_. I’m not sure though if this is the case. Dave had submitted feedback about an issue when the blog does not use the standard names for the tables. I’ll fix this this when I have time. For now, you can rename the table names in the plugin code.

    Dave: The recent comments are printed as an unordered list by default. You can prepend or append any HTML code. In your case you should also tweak the way each comment (list item) is printed inside the loop, because the simple default list is not what you are after. Perhaps you should talk to a theme author for further info on this.

  14. don Permalink →

    It’s not working for me. I added it to the right directory but it’s not showing up for me to activate. I have no clue what to do.

    I’m hosting the site on Yahoo Web Hosting.

  15. George Notaras Post authorPermalink →

    Don: You probably need to make the file world-readable. This is why the web server cannot read it and consequently it is not shown in the plugin list in WordPress. You can change the file’s permissions with an ftp client.

  16. alper Permalink →

    there is a problem with the link to the comments. the default output is

    $output .= "
    	<a>ID) . "#comment-" . $comment->comment_ID  . "\" title=\"My title here: " . $comment->post_title . "\">" . $comment->comment_author . "</a>: " . strip_tags($comment->com_excerpt) . "...";
    

    but on each single-page, the comment id becomes 1-2-3…

    i hope i was clear.

    in other words, the comment plugin redirects me to #comment-21 for instance. but it is actually comment-1

  17. George Notaras Post authorPermalink →

    Hi Alper,
    First of all, I should tell you that I have stopped the development of all the plugins I have released so far because of lack of free time. However, until now, they work without problems with wordpress.

    I had a look at the way comments are displayed on your blog and it seems that either your theme or another plugin does not display the comments as the default wordpress does. As you can see in my blog each comment has the following structure:

    - Author
    - Date and Time
    - Comment body
    

    The “Date and Time” part is a link to the comment. This exact link is constructed by this plugin so that it leads to the actual comment from the recent-comments list.

    I am afraid I cannot do anything about this. This is neither the plugin’s nor your theme’s problem. It seems that there is an incompatibility between them. Unfortunately, I do not have the time to investigate this right now. What I recommend is to try another recent-comments plugin. If that doesn’t work, I believe you should contact the theme’s author.

  18. Tibet Permalink →

    Great plugins. Thanks for creating it.

  19. kim Permalink →

    i like the simplicity of this plugin but there is one problem i get when i use it, the link title that’s supposed to say “On ‘name of post'” only says “on”. why doesnt it show the permalink title? how can i fix it? thank you!

  20. George Notaras Post authorPermalink →

    Kim, I really do not understand why this is happening. Every comment record in the wp database has a post_title field, which is read by this plugin. As you can see in my blog’s (v2.0.5) front page, it works as expected. Could you provide any more information about what version of WordPress you use or which theme?

  21. Torley Permalink →

    Hello! First, thanx so much for this great plugin, it’s definitely an improvement over the original. I’ve been using Mika’s widget version and came back to this page after following the “virtual breadcrumbs”.

    I noticed something that appears to be a bug: when a comment has formatting tags in it, it doesn’t end with an ellipsis “…” as it’s supposed to. Instead, it just cuts right off. I noticed this odd behavior on my blog.

    Can you please verify if this is a known issue, GNot? Thanx so much!

  22. Torley Permalink →

    Hmmm I’m testing with a styled block just to see what happens here.

  23. Torley Permalink →

    Interesting, Gnot. I still see the ellipsis on your site, even after I styled the text. I wonder what’s different on mine… I’ll do some more digging…

  24. George Notaras Post authorPermalink →

    Hi Torley,
    This is how the plugin works:
    1. It retrieves the first N characters of each comment (by default N is 60 characters, but it can be customized). These N character contain both the actual comment and any possible HTML tags.
    2. Each comment becomes a list item. Any HTML tags are stripped and the “…” is added at the end of the comment.

    So, if the comment has formating HTML tags in the first, for example, 60 characters, for example:

    Test test <a href="http://www.example.org" title="some title goes here">testing for Torley</a> test end

    Then this is what will appear as the comment:

    Test test ...

    As you can see, the “testing for Torley” part is completely missing because it is after the 60th character of the comment.

    This is not a bug. Only the specified number of characters is retrieved from the database for each comment, so to reduce the server load. This functionality is not going to change. Sorry.

  25. Torley Permalink →

    GNot, thank you very much for the detailed help! I was confused about that, I think, and you helped clarify it. Much appreciation. :)

  26. dave Permalink →

    awesome plugin. really appreciated your clear installation instructions.

  27. Payam Permalink →

    Hello,

    I’ve tried everything to format the list of recent comments, but none of them are getting formatted. I created a style and set it as an id to the li style… nothing…

    Can someone help me out? You can look at my site and see how it looks… I want each comment to have a little bullet in front…

    Thanks!

  28. Henry Permalink →

    Hi, sorry to be a pest. But is there anyway to change the code so that the permalink is displayed next to author name and the excerpt displayed as tooltip?

    thanks

  29. George Notaras Post authorPermalink →

    Hi Henry. It is possible by modifying line 83 in the plugin source. I intend to add some pre-defined formats of displaying the recent comments in future versions, but currently I do not have the time for this.

  30. Blake Permalink →

    I know you aren’t supporting this because you probably have to do some paying work in order to eat, but I wanted to ask if it’s possible to use this within the body of the post, with a few mods. I’m not all that familiar with how to move things in and out of the sidebar and keep wordpress happy so I thought I’d ask.

    Thanks for creating this!

  31. Blake Permalink →

    Never mind, please delete my question because it *does* work. I should have tested it first!

  32. Carl Permalink →

    Is there a way to get it to list the name of the post where it gives the comment excerpt?