My First WordPress Plugin – Recent Comments

Filed in: WordPress, WordPress Plugins — January 4th, 2005

advertisement

Intro LcF’s Recent Comments: I don’t understand why people like to have recent comments shows the comment text instead of the post title.

My recent comment plugin display in format of nickname @ post title. ‘Nickname’ will be linked to comment author’s website(if submited), ‘post title’ will be linked to the comment’s permalink, AND mouseover it to preview the comment text!

Updated (2005-04-22): This script works on Wordpress 1.5!

Not really my original work… I have forgotten the orginal author name. The script is using in previous version of WordPress where no plugin support(put in my-hacks.php). I modified it to have my own style of displaying recent comments.

Now I upgraded to WordPRess 1.2.2 (works in WP1.5), I think it is time to dump the old my-hack.php and use only Plugin. I need to convert the script into a WordPress plugin…

Well, it is much simpler than I thought. In fact, no need to modify single bit of the code. I just add some plugin comments and save the file as lcf_recent_comment.php. :)

Dump the file into my wordpress plugin folder, then goto “Plugins” under WordPress Admin, and my plugin is listed there! Activate it, and add lcf_get_recent_comments(); php function(don’t complain about the function name, initially it is MY function. :P ) into template. Done!

If you like the recent comment list in my blog(see it?), you can download here.

Hope you like it! Any feedback is welcome!

Popularity: 2% [?]

Bookmark and Share

Read also:

What do you think? 30 Responses to “My First WordPress Plugin – Recent Comments”

Comments Feed | TrackBack URL
  1. #1
    Leona Says:

    thanks for the plugin, works great!

  2. #2
    David July Says:

    I would love to have the ability to truncate the topic title to an ellipsis if it is longer than x characters.

    For example:
    Commenter @ This is a really long…

  3. #3
    Boldt Says:

    I have installed your plugin, but have some problems.

    I want only the first 10-15 words of the comment shown so I have added this:

    ‘, true) ?>

    but the complete comment is shown. what is wrong?

    regards

  4. #4
    Boldt Says:

    sorry the line didn’t show correct

    lcf_get_recent_comments(10, 25, ”, ”, true)

  5. #5
    Boldt Says:

    found the bug/error

    Line 41 in lcf_get_recent_comments.php where output is defined:

    replace “$comment_content” with “$comment_excerpt”

  6. #6
    Sylvain Says:

    Jeeeeeeeeeeeeeeezuz! Been looking for that like a mad man! Great work! You’re on my “Acknowledgments” roll! :-)

  7. #7
    LcF Says:

    @Sylvain: glad that you like it too. :)

  8. #8
    Yvonne Foong’s Blog » Wordpress shifted and New Additions Says:

    [...] ess blog. The priority of a post depends on its comments. More comments, higher priority! RECENT COMMENTS- As what it is called. This plugin [...]

  9. #9
    mgirl Says:

    Been searching the last hour for the perfect comment plugin and i found it here.. thanks LCF. you rock.

  10. #10
    JH Says:

    Hey LcF:

    Fantastic plugin. I spent a good two hours looking for a tool that would allow me to do exactly what yours does. After I had nearly given up all hope…I found you. Many, many thanks.

    I’d like to make a slight modification, if it doesn’t offend, but don’t know how. Perhaps you can help?

    I don’t want the comment author’s to link to their url in the menu (it will still be linked from the comment itself). How do I adjust to code so only the comment title itself is a hotlink, not the author’s name?

    Also, I attempted to change the number of comments listed (from 5 to 7) and it generate a host of error messages from wordpress about the header already being generated.

    I’m a complete novice when it comes to this stuff, so any assistance you can offer will be greatly appreciated.

    Jacqui

  11. #11
    aHfUi Says:

    Lcf,
    Thanks your plug-in
    It is nice ^___^

  12. #12
    stchatterbox Says:

    good if you could add a gravatar beside the commenter!

  13. #13
    LcF Says:

    thank you for the suggestion, stchatterbox.

  14. #14
    Pande Says:

    Your plugin is great. Works perfect on Wordpress 2.0 too.
    Thanks.

  15. #15
    Rado Vleugel Says:

    Hey LcF,

    Thanks for this plugin. I have a question: Is there a way to list also the comments made on pages (I have for example a Guest Book with a template that makes use of the same comment-code as the normal post-pages)? At this moment only comments made on posts are listed.

    Rado

  16. #16
    sadkas Says:

    hi your plugin is very useful. but i want to prevent seek website name. what can i do?

  17. #17
    Marcela Says:

    hello LcF,

    Is this plugin compatible iwth wp 2? thanks.

  18. #18
    LcF Says:

    Yes, the plugin should works with WordPress 1.5 and above.

  19. #19
    John Wong Says:

    Nice plugin! Will implement it soon! Thanks for your contributions!

  20. #20
    yemendiary Says:

    Fantastic! Works like a charm. FYI for whom need the exact code to add to your sidebar, here ya go:

    [Note: Code is ripped automatically by WordPress... ]

    Add the above to top and bottom portions of code in the sidebar.

  21. #21
    无聊小站 » Blog Archive » 我用的plugins Says:

    [...] LCF Recent Comments [...]

  22. #22
    Jonna Says:

    Personally, I just dont git. how couple most people not understand all of this? Anyway. My 2pennies : )

    Jonna

  23. #23
    Ian C. Says:

    Nice – thanks :)

  24. #24
    Quang Minh Says:

    Thanksssssssssssssssss a lot man :D
    I love the simplicity of your plugin, I only need 2 thing for the recent comment: author + topic link; and your plugin provided it, simple and yet effective.

    Just one small thing to point out, sometimes the author is “Anonymous”, your plugin will show “” (blank) in the author name, I modified it a liite bit to show “Anonymous” instead of blank name :D Maybe you want to consider it to update the plugin. Otherwise, it’s PERFECT :)

    Thanks again, and Happy new Year :)

  25. #25
    Sherly Says:

    Thanks for the nifty plugin, it is running perfectly in my website. I also modified the code to display Anonymous just like what Quang MIngh suggested :

    “if ($comment->comment_author != “”){
    $comment_author = stripslashes($comment->comment_author);
    }
    else {$comment_author=’Anonymous’;}”

  26. #26
    alex Says:

    Hi, Thanks Liew for the plugin. I have it up and running on my blog. Marcela, I’m using WordPress 2.1, so it should be no problem with WordPress 2.0. ;-)

  27. #27
    10 Essential Plug-ins for WordPress version 2.1 : www.Recruiting-USA.com Says:

    [...] Recent Comments – shows recent comments with link back to commenter’s site and link to comment (by Liew Cheon Fong and available on his blog) [...]

  28. #28
    Maryland Says:

    This nice is very good, i will recomend it to my friends and partners

  29. #29
    10 Essential Plug-ins for WordPress Version 2.1 - Meta Tags : www.Recruiting-USA.com Says:

    [...] Recent Comments – shows recent comments with link back to commenter’s site and link to comment (by Liew Cheon Fong and available on his blog) [...]

  30. #30
    Tom Says:

    Line 41 in lcf_get_recent_comments.php where output is defined:

    replace “$comment_content” with “$comment_excerpt”
    need helppp

Comments are closed. Submit your comment here