G-Loaded Journal

« Creative-Commons-Configurator WordPress Plugin
Fedora Core 5 Test 2 Review »

Simple-Recent-Comments WordPress Plugin

January 15th, 2006 by --> George Notaras

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.

Downloads, Issue Tracking, Support

For the latest releases of Simple-Recent-Comments please visit the downloads section of the Simple-Recent-Comments Development Portal.

The development website also hosts an issue tracking facility, where you can submit your feature requests or report bugs, and discussion boards, where you can get first class support from the community of users.

Donate

This plugin is released as free software. Nevertheless, its development requires time and effort. A small donation, as a sign of appreciation of the effort, is welcome. Please, use the following button to visit the Donations page. Thanks in advance for your support!

spacer

Got Widgetized!

Mika Perälä has taken the time to make a sidebar widget out of this small plugin. Download here
Excellent work!

Themes That Include Simple-Recent-Comments

This plugin’s code has been integrated in the following WordPress themes:

XiAP Design‘s WordPress themes. Excellent and original designs. Previews, demos and downloads are available on their website.

Nick La has integrated this plugin in the unique and popular GlossyBlue theme. Demo is also available.

Rob Goodlatte has designed the very attractive and functional theme named Abstractia.

I would like to backlink to every theme that uses the simple-recent-comments code, but it is impossible to scan the web for such themes. If your theme is not listed and you care adding it in the above list, feel free to contact me.

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(); ?>

If you have integrated the plugin into your theme in any way, I would greatly appreciate it if you included some credit and a link to simple-recent-comments homepage in your theme’s information or download page.

Thanks in advance :)

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

This plugin has been written by George Notaras.

The Simple-Recent-Comments WordPress Plugin by George Notaras, unless otherwise expressly stated, is licensed under a Creative Commons Attribution-Noncommercial-Share Alike 3.0 Unported License.

Tags: Plugins, Software, Wordpress

34 Responses to “Simple-Recent-Comments WordPress Plugin”

  1. Matt Says :
    February 9th, 2006 at 11:57 pm

    Cool work

  2. Robin Says :
    February 11th, 2006 at 10:29 pm

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

  3. Christiaan Says :
    February 12th, 2006 at 10:08 pm

    Stubbornly refused to show up on my plugins admin page. Same with Add-Meta-Tag.

  4. Gnot Says :
    February 13th, 2006 at 7:03 pm

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

  5. Mika Perälä Says :
    April 5th, 2006 at 4:41 am

    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. Gnot Says :
    April 5th, 2006 at 4:58 am

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

  7. Dave Says :
    April 17th, 2006 at 7:51 pm

    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 da.vebrig.gs, and it shows up fine, only the comments displayed are the most recent comments from my old blog, davebriggs.net, 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 Says :
    April 17th, 2006 at 9:15 pm

    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. Gnot Says :
    April 17th, 2006 at 9:23 pm

    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. Gnot Says :
    April 17th, 2006 at 9:26 pm

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

  11. Dave Says :
    April 17th, 2006 at 9:45 pm

    Yep, thanks Raoul – 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

  12. Helge Says :
    April 22nd, 2006 at 5:28 pm

    I get the follwing 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

  13. Dave Says :
    April 23rd, 2006 at 9:29 pm

    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 indivual 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

  14. Gnot Says :
    April 24th, 2006 at 8:31 pm

    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.

  15. don Says :
    April 26th, 2006 at 4:04 pm

    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.

  16. Gnot Says :
    April 26th, 2006 at 8:13 pm

    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.

  17. alper Says :
    May 6th, 2006 at 8:26 pm

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


    $output .= "
    <a>ID) . "#comment-" . $comment->comment_ID . "\" title=\"Şuna yorum yazmış: " . $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

  18. Gnot Says :
    May 6th, 2006 at 9:48 pm

    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.

  19. ProTibet Says :
    October 14th, 2006 at 2:49 am

    Great plugins. Thanks for creating it.

  20. kim Says :
    November 5th, 2006 at 4:57 am

    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!

  21. GNot Says :
    November 5th, 2006 at 6:07 am

    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?

  22. Torley Says :
    November 5th, 2006 at 10:43 pm

    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 elipsis” …” 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!

  23. Torley Says :
    November 6th, 2006 at 5:41 am

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

  24. Torley Says :
    November 6th, 2006 at 5:42 am

    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…

  25. GNot Says :
    November 6th, 2006 at 6:27 am

    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 class="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.

  26. Torley Says :
    November 6th, 2006 at 9:03 am

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

  27. dave Says :
    November 10th, 2006 at 4:14 am

    awesome plugin. really appreciated your clear installation instructions.

  28. Payam Says :
    December 8th, 2006 at 11:47 pm

    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!

  29. Henre Says :
    January 17th, 2007 at 1:05 pm

    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

  30. GNot Says :
    January 17th, 2007 at 1:41 pm

    Hi Henre. 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.

  31. Blake Says :
    February 6th, 2007 at 8:09 pm

    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!

  32. Blake Says :
    February 6th, 2007 at 8:19 pm

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

  33. Carl Says :
    February 7th, 2007 at 7:47 am

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

  34. Kerala Houseboats Says :
    September 27th, 2011 at 9:54 am

    Your installation description is highly appreciated…

Comments have been de-activated on this post.



gipoco.com is neither affiliated with the authors of this page nor responsible for its contents. This is a safe-cache copy of the original web site.