I got a copy of this from someone else, since MtDew’s site is currently disassembled. I made a couple of small tweaks to make it more of a drop in item (specifically, I added a title/header, expanded the length of the comments, and made it output a list like the other sidebar items).
--- recent_comments.php.orig Thu Jul 22 22:17:52 2004
+++ recent_comments.php Thu Jul 22 22:17:47 2004
@@ -8,13 +8,13 @@
Author URI: https://mtdewvirus.com/
*/
-function get_recent_comments($no_comments = 5, $comment_lenth = 5, $before = '
- ', $after = '
', $show_pass_post = false, $comment_style = 0) {
+function get_recent_comments($no_comments = 5, $comment_lenth = 25, $before = '
- ', $after = '
', $show_pass_post = false, $comment_style = 0) {
global $wpdb, $tablecomments, $tableposts;
$request = "SELECT ID, comment_ID, comment_content, comment_author, post_title FROM $tablecomments LEFT JOIN $tableposts ON $tableposts.ID=$tablecomments.comment_post_ID WHERE post_status = 'publish' ";
if(!$show_pass_post) $request .= "AND post_password ='' ";
$request .= "AND comment_approved = '1' ORDER BY comment_ID DESC LIMIT $no_comments";
$comments = $wpdb->get_results($request);
- $output = '';
+ $output = '<li id="comments">Recent comments:<ul id="recent_comments">';
foreach ($comments as $comment) {
$comment_author = stripslashes($comment->comment_author);
$comment_content = strip_tags($comment->comment_content);
@@ -32,6 +32,7 @@
$output .= '" title="View the entire comment by ' . $comment_author.'">' . $comment_excerpt.'' . $after;
}
}
+ $output .= '
';
echo $output;
}
?>
I’d like to merge the two presentations so that the post, the author, and the comment itself appear: do I post any changes here or is there a Better Way?
PS: WordPress rocks!