Categories
Package/plugin/module WordPress

Plugin: Customizable Comment Listings

This plugin has been updated! Comments to this post are now closed. For the latest download, documentation, and link for posting new comments related to this plugin, visit the plugin’s new homepage at:
coffee2code.com/wp-plugins/customizable-comment-listings
Name:
Customizable Comment Listings
Author:
Scott Reilly
Version:
0.9
Last updated:
30 March 2005
Description:

Display Recent Comments, Pingbacks, and/or Trackbacks, as well as other comment listings using the comment and/or post information of your choosing in an easily customizable manner. You can narrow commentt searches by specifying post IDs, comment types, and/or comment status, among other things.

Notes:

List of percent substitution tags supported:

"%comment_author%", // Name of commenter "%comment_author_email%", // E-mail of commenter "%comment_author_ip%", // IP of commenter "%comment_author_url%", // URL of commenter "%comment_author_URL%", // Linked (if URL provided) name of commenter "%comment_date%", // Date for comment "%comment_excerpt%", // Excerpt for comment "%comment_excerpt_URL%", // Excerpt for comment hyperlink to full comment "%comment_id%", // ID for content "%comment_link%", // URL to comment (same as %comment_url%) "%comment_text%", // Full content of the comment "%comment_time%", // Time for comment "%comment_type%", // Type of comment ('comment', 'pingback, or 'trackback') "%comment_url%", // URL to comment /* THESE PERTAIN TO commenters MODE (and only work in commenters mode) */ "%total_comments%", // Total number of comments for a commenter /* THESE ALL PERTAIN TO THE RESPECTIVE COMMENT'S POST */ "%allcomments_count%", // Number of comments + pingbacks + trackbacks for post "%allcomments_fancy%", // Fancy reporting of allcomments "%comments_count%", // Number of comments for post "%comments_count_URL%", // Count of number of comments linked to the top of the comments section "%comments_fancy%", // Fancy reporting of comments: (see get_recent_tagmap()) "%comments_fancy_URL%", // Fancy reporting of comments linked to comments section "%comments_url%", // URL to top of comments section for post "%comments_URL%", // Post title linked to the top of the comments section on post's permalink page "%pingbacks_count%", // Number of pingbacks for post "%pingbacks_fancy%", // Fancy report of trackbacks "%post_author%", // Author for post "%post_author_count%", // Number of posts made by post author "%post_author_posts%", // Link to page of all of post author's posts "%post_author_url%", // Linked (if URL provided) name of post author "%post_content%", // Full content of the post "%post_date%", // Date for post "%post_excerpt%", // Excerpt for post "%post_excerpt_short%", // Customizably shorter excerpt, suitable for sidebar usage "%post_id%", // ID for post "%post_modified%", // Last modified date for post "%post_status%", // Post status for post "%post_time%", // Time for post "%post_title%", // Title for post "%post_url%", // URL for post "%post_URL%", // Post title linked to post's permalink page "%trackbacks_count", // Number of trackbacks for post "%trackbacks_fancy", // Fancy reporting of trackbacks

Installation:
  1. Download the file customizable-comment-listings.zip and unzip it into your /wp-content/plugins/ directory.
    -OR-
    Copy and paste the the code ( customizable-comment-listings.phps ) into a file called customizable-comment-listings.php, and put that file into your /wp-content/plugins/ directory. Please ensure you do not introduce any spaces or other characters before the <?php or after the ?>
  2. Optional: Change configuration options in the file to your liking. In-code comments should help you there.
  3. Activate the plugin from your WordPress admin ‘Plugins’ page.
  4. Include one or more of the templates defined below into your index.php
Functions:

function c2c_get_comments ($limit = 5, $format = "", $mode = 'comments', $types = 'comment pingback trackback', $status = '1', $ids = '', $order = 'DESC', $offset = 0, $date_format = 'm/d/Y', $include_passworded_posts = false )

function c2c_get_recent_comments( $limit = 5, $format = "<li>%comment_author%: %comment_excerpt_URL%</li>", $types = 'comment pingback trackback', $status = '1', $ids = '', $order = 'DESC', $offset = 0, $date_format = 'm/d/Y', $include_passworded_posts = false )

function c2c_get_top_commenters( $limit = 5, $format = "<li>%comment_author_URL% (%total_comments%)</li>", $types = 'comment pingback trackback', $status = '1', $ids = '', $order = 'DESC', $offset = 0, $date_format = 'm/d/Y', $include_passworded_posts = false )

function c2c_get_recent_commenters( $limit = 5, $format = "<li>%comment_author%: %comment_excerpt_URL%</li>", $types = 'comment pingback trackback', $status = '1', $ids = '', $order = 'DESC', $offset = 0, $date_format = 'm/d/Y', $include_passworded_posts = false )

  • $limit : The number of comments to list/return; default is 5
  • $format : A string that uses percent substitution tags to define the data you want displayed for each listing and how you want it displayed;set it to ” (two single-quotes) to return an array of the requested comment objects without outputting anything.
  • $mode : The manner in which comments are to be considered, either ‘comments’, ‘recentcommenters’, or ‘topcommenters’
  • $types : A space-separated list of comment types to include; can be any combination of ‘comment’, ‘pingback’, and/or ‘trackback’
  • $status : A space-separated list of comment status values to include; can be any combination of ‘1’ (approved comments), ‘0’ (unapproved comments), and/or ‘spam’ (spam, obviously).
  • $ids : A space-separated list of post IDs with which to limit the search for the comment listings
  • $order : The order with which the comment listing should be sorted, either ‘ASC’ (for ascending) or ‘DESC’ (for descending); default is ‘DESC’
  • $offset : The number of comments to skip; default is 0
  • $date_format : Date format string, PHP-style, if different from the blog’s default date-format string
  • $include_passworded_posts : A boolean value, either ‘true’ or ‘false’, indicating if passworded posts should be considered in the comment search
Tips & Examples:

The simplest examples would be the following (for brevity’s sake, in the examples I’m going to specify 3 as the number of posts I want returned):

<ul>Recent Comments <?php c2c_get_recent_comments(3); ?> </ul>

Would output something like:


<ul>Recent Commenters <?php c2c_get_recent_commenters(3); ?> </ul>

Would output something like:

    Recently Commenters

  • John: Ha! That was so funny I…
  • Sarah: I’ve got a story that will…
  • Tom Jones: Haven’t you heard of the red…

<ul>Top Commenters <?php c2c_get_top_commenters(3); ?> </ul>

Would output something like:


But what you may really want is to run the Recent Comments calls and customize the listing output. That’s where the percent substitution tags come into play. The $format argument to each of the functions above is a string that represents how each commentt found by the function should be output. Any percent tags (as listed and defined above) will be replaced with the appropriate data.

So, let’s say you only want to list the most recent comment, to include the comment author’s name linked to that person’s site (if they provided an URL), plus a short excerpt of the post, plus the title of the post the comment appeared in linked to the post itself. You’d do this:

<ul> <?php c2c_get_recent_comments(1, "<li>%comment_author% said \"%comment_excerpt%\" in <br />%post_URL%</li>"); ?> </ul>

Which would output something like:

Release Log:
  • 30 Mar 2005 : v0.9 — Released to the public
Copyright & Disclaimer:

Copyright (c) 2005 by Scott Reilly (aka coffee2code)

Permission is hereby granted, free of charge, to any person obtaining a copy of this software and associated documentation files (the “Software”), to deal in the Software without restriction, including without limitation the rights to use, copy, modify, merge, publish, distribute, sublicense, and/or sell copies of the Software, and to permit persons to whom the Software is furnished to do so, subject to the following conditions:

The above copyright notice and this permission notice shall be included in all copies or substantial portions of the Software.

THE SOFTWARE IS PROVIDED “AS IS”, WITHOUT WARRANTY OF ANY KIND, EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE.

Acknowledgements:
N/A

82 replies on “Plugin: Customizable Comment Listings”

WordPress Plugin: Customizable Comment Listings

Customizable Comment Listings will display recent comments, pingbacks, and/or trackbacks, as well as other comment listings using the comment and/or post information of your choosing in an easily customizable manner. You can narrow comment searches by …

Great plugin.

One problem I have with it is that I cannot manipulate the date format. If I include $date_format = 'D. j F Y' or 'D. j F Y' in the function, the comments do not show up (but no errors are thrown on the page).

How exactly are you calling the function? An example of defining a custom date format:

<?php c2c_get_recent_comments(5, "[%comment_date%] %comment_author%: %comment_excerpt_URL%", 'comment pingback trackback', '1', '', 'DESC', 0, 'D. j F Y'); ?>

You have to define all the function arguments leading up to the one you want to change.

Hey, Scott:

Is there a way to use this *along with* Customizable Post Listings? When I try to enable it with CPL already installed, I get:

Fatal error: Cannot redeclare c2c_comment_count() (previously declared in [snip] customizable-comment-listings.php:197) in [snip] customizable-post-listings.php on line 136

Jeff: There will be. I’ve been delayed in getting the latest release of Customizable Post Listings out the door, which will (among other things) not cause this conflict, which is arising because the Customizable Comment Listings needs a function that CPL also needs. CCL checks to make sure the function wasn’t already defined, whereas CPL does yet do that check. In the menatime, you could always rename the function c2c_comment_count() in CPL to some nonsense, if you plan on having CCL also activated. CPL should be updated by the end of the weekend.

Thanks! I was going to try yanking that function from CPL (since I wasn’t messing with comments in my CPL setup anyway), but it seemed excessively violent; I thought I’d ask first. 😉

I receive an undefined function error: get_comment_link() in
$new = “$new“;

on line 289. When I take out this string it works, but loose the linking to the comments listed. Why would it cause an error you think?

This is the string I use in the index:

Hey, why do I keep getting a “fatal error” on my webpage when I try to insert the codes into my sidebar template? It keeps saying there’s an undefined function…

I’m doing the following on my template:

Recent Comments
Recent Comments

Is there something I’m missing? I’ve uploaded the zip file and unzipped it into my wp-plug-ins directory, and it shows as activated…should I be doing something else?

Could it be that I’m using the 3-column Kubrick? Or have I coded improperly?

Hi,
I’m trying to display the comment excerpt in the tool-tip of the link using the “a title” tag, but it only shows the first word of the string. This is how I’m calling the function:


%comment_author_URL% on <a href="%comment_link%" title="%comments_excerpt%" rel="nofollow">%post_title%</a>"); ?&gt;

I tried several different percent substitution tags, but each time it only shows the first word in the tool tip. If I hard code a string it shows the full string.

Any idea what the problem could be? Thanks

Hi, I installed your plug-in. Now, on my wp-admin pages, the following text appears in my headers:

Warning: Cannot modify header information – headers already sent by (output started at /home/typeoff-de/htdocs/wp-content/plugins/customizable-post-listings.php:2) in /home/typeoff-de/htdocs/wp-admin/admin.php on line 6

Warning: Cannot modify header information – headers already sent by (output started at /home/typeoff-de/htdocs/wp-content/plugins/customizable-post-listings.php:2) in /home/typeoff-de/htdocs/wp-admin/admin.php on line 7

Warning: Cannot modify header information – headers already sent by (output started at /home/typeoff-de/htdocs/wp-content/plugins/customizable-post-listings.php:2) in /home/typeoff-de/htdocs/wp-admin/admin.php on line 8

Warning: Cannot modify header information – headers already sent by (output started at /home/typeoff-de/htdocs/wp-content/plugins/customizable-post-listings.php:2) in /home/typeoff-de/htdocs/wp-admin/admin.php on line 9

When I try to post or comment, I get similar errors as well. Do you want what I am doing wrong?

(I’m hgoing to take the plug-in out for now, but I really like it, and would like to put it back in!)

Love the plug in, used it on 3 sites I’ve put together for people… 1 question though.

I’ve changed the $ types to ‘comment’ only as I don’t want pingbacks listed but it makes no difference, have I missed something?

is it possible to reduce the number of words that is extracted from comment excerpt? it shows too many words for my liking on my sidebar. thanks for any responses!

Hi, Scott. The only function I see missing from this plugin is the ability to filter comments by cat_ID. I could REALLY use most recent comments and top commentors per cat_ID.

Any chance you’ll soon update the plugin to do this?

I just want to be able to show the number of comments from a specific post.. how can I do this? I can;t figure out how to write it. I am using Customizable-comment-listing.php as well.

I am trying to use the plugin, but when I unzipped the file, my WordPress blog doesn’t display anymore. Is there something wrong with the php file?

Thanks.

[…] Pois e não é que quando uns não funcionam procuramos outros certo? Se o Costumizable Comments Listing não está a dar tentamos o Brian’s Latest Comments e não é que até gostamos da coisa??? Deu trabalho até ficar como eu queria mas já está e como tal, o melhor é não mexer mais. O problema maior foi por a coisa a validar correctamente mantendo um aspecto semelhante no IE e no Firefox. Já dá. Como também já tratei das datas, agora vou mesmo é dormir que está quase na hora de levantar. […]

Scott, all I can say it’s a great plugin! I’m using your plugin a lot. I’m currently testing my website and it doesn’t validate xhtml transitional. Because of your plugin! lol… Since I don’t have a lot of content there is one c2c_get_recent_posts() that return nothing, because the category is empty. w3c validator says:


end tag for "ul" which is not finished.

                  

Most likely, You nested tags and closed them in the wrong order. For example <em>... is not acceptable, as <em> must be closed before . Acceptable nesting is: <em>...</em>

Another possibility is that you used an element which requires a child element that you did not include. Hence the parent element is "not finished", not complete. For instance,  generally requires a , lists (ul, ol, dl) require list items (li, or dt, dd), and so on.

Can you extend your code to return an empty () when the return is empty?

[…] Durch den Artikel von Robert inspiriert, habe mich auf die Suche nach Plugins begeben, die die Datenbankabfrage nach oben drücken. Robert gibt dazu ja schon eine Menge an Tipps und viele seiner Kommentare erläutern noch mehr Hintergründe. Nun, ich wollte aber auf die Darstellung meiner Startseite nicht unbedingt verzichten. Die Posts und Kommentare habe ich bisher mit dem Plugin „Customizable Comment Listings“ in die Seite geladen. Leider drückt das Plugin die Querie-Abfrage enorm hoch. In meinem Fall möchte ich die letzten 10 Beiträge und Kommentare auf der Startseite darstellen, deshalb habe ich mich dafür entschieden, das ganze mit dem RSS-NewsFeed zu ermöglichen. Mit der hier vorgestellten Lösug konnt ich mehr als 40 Anfragen, welche das Plugin duchführte, beseitigen. Auf anderen Blogs, wo ich WP als CMS einsetze, habe ich so ebenfalls einige Anfragen (ca. 20 Queries) unterbinden können. In den Fällen stelle ich nur die letzten Kommentar im Sidebar dar, bzw. auf einer extra Seite. […]

hi. i really like this plugin. just one issue though…

whenever i use the excerpt, be it the short or the regular for say 5 recent posts, the excerpts display the same text for different posts. Please help me with this issue.

Is there a way that the plugin can extract random posts under a certain category number?

Hello I am sorry to bother you – I really tried to figure this out. I have your plug in set for Recent Commenters. When someone who has commented on my blog before posts a new comment it shows a past comment from them not the most recent? Any ideas on what I did wrong. I have everything set for Descending. .Thank you – I really appreciate it! Fantastic plugin!

How can I include this code and where ?
Plesae Help me.
Thanks
4. Include one or more of the templates defined below into your index.php

Functions:
function c2c_get_comments ($limit = 5,
$format = “”,
$mode = ‘comments’,
$types = ‘comment pingback trackback’,
$status = ‘1’,
$ids = ”,
$order = ‘DESC’,
$offset = 0,
$date_format = ‘m/d/Y’,
$include_passworded_posts = false )

Hello I am still trying ot figure this out – I am sorry to bother you. . .I have your plug in set for Recent Commenters. When someone who has commented on my blog before posts a new comment it shows a past comment from them not the most recent? Any ideas on what I did wrong. I have everything set for Descending. .Thank you – I really appreciate it! Fantastic plugin!

Hello Scott,

This is a terrific plugin. I read in an old post that there was the possibility to include the “category” to which the post belongs. Is this possible?

Thanks and congratulations for this beautiful piece of code.

Diplo

hi i love the plugin my ony problem is, if i try to activate it and customizable post listing, it causes wordpress to conk out. any thoughtson what causes this or how to fix?

Comments are closed.