WordPress: Comment Plug

If you’re using WordPress, this simple tutorial will show you how to include a list of of all the people who have commented on your blog entry.

First, you will need to open index.php located in your theme folder.

Then paste the following PHP code anywhere on the page.

<?php
function comment_plugger
($show = 1, $limit = 0, $sep = ' ', $none = ' none') {
 global $wpdb, $tablecomments, $id;
 $cid = ($show) ? ($id - 1) : $id;
 $request = "SELECT DISTINCT comment_author_url,
comment_author
FROM
$tablecomments";
 $request .= " WHERE comment_post_ID='$cid' 
AND 
comment_author <> ''
AND
comment_author_url <> ''";
 $request .= ' ORDER BY comment_author ASC';
 $request .= ($limit > 0) ? "LIMIT $limit" : '';
 $commenters = $wpdb->get_results($request);
  if ($commenters) {
  $output = '';
   foreach ($commenters as $commenter) {
   if (!empty($commenter->comment_author_url)) {
   $output[] = '<a href="'.$commenter->
comment_author_url.'"
title="'.$commenter->comment_author.'">'.$commenter->
comment_author.'</a>';
            }
        }
    }
    if (is_array($output)) {
        $sep = ", ";
        echo implode($sep, $output);
    } else {
        echo $none;
    }
}
?>

Select a place you would like the plugs to show up. Then paste the following code where you would like them to appear:

<?php comment_plugger(0); ?>

The above code will show commentators from the current entry. Change the 0 to a 1 if you would like to show commentators from the previous entry.