All pastes #625370 Raw Edit

Something

public text v1 · immutable
·published 2007-07-18 21:54 UTC
rendered paste body
function comment_plugger($before = 'Comments by: ', $limit = 0, $sep = ', ') {
        global $wpdb, $tablecomments, $id;
        $request  = "SELECT comment_author, comment_author_url, MAX(comment_ID) as comment_ID FROM $tablecomments";
        $request .= " WHERE comment_post_ID='$id' AND comment_approved = '1' GROUP BY comment_author, comment_author_url ORDER BY comment_ID DESC";
        $request .= ($limit > 0) ? " LIMIT $limit" : '';
        $commenters = $wpdb->get_results($request);

        if ($commenters) {
                $output = '';
                $commenters = array_reverse($commenters);
                foreach ($commenters as $commenter) {
                        if (!empty($commenter->comment_author_url)) {
                                $output[] = '<a href="' . $commenter->comment_author_url . '">' . $commenter->comment_author . '</a>';
                        }
                        else {
                                $output[] = $commenter->comment_author;
                        }
                }

                if (is_array($output)) {
                        echo $before.implode($sep, $output);
                }
        } else {
//      echo "None yet.";
        }
}
?>