Fix for recent-comments WP plugin

I noticed that un-apparoved comments (mostly ads for online poker) were showing up in my “recent comments” section on
So I poked around and.. found a bug!
So here I present a patch for recent-comments.php, the plugin file I use to generate that list.

Index: recent-comments.php
RCS file: /home/rae/cvsroot/sites/,v
retrieving revision 1.1
diff -u -b -w -r1.1 recent-comments.php
--- recent-comments.php 17 Jan 2005 19:59:23 -0000 1.1
+++ recent-comments.php 9 Feb 2005 20:08:12 -0000
@@ -10,7 +10,7 @@

function get_recent_comments($no_comments = 5, $comment_lenth = 5, $before = '<li>', $after = '</li>', $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 AND post_status = 'publish' ";

+ $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);

Oooh, I feel so accomplished.
I just changed an AND to a WHERE.
It was ignoring the bit about comment_approved = '1'.

I did this while I was eating pizza at my desk at entrac.

Published by


Mac developer

One thought on “Fix for recent-comments WP plugin”

Leave a Reply

Your email address will not be published. Required fields are marked *

To create code blocks or other preformatted text, indent by four spaces:

    This will be displayed in a monospaced font. The first four 
    spaces will be stripped off, but all other whitespace
    will be preserved.
    Markdown is turned off in code blocks:
     [This is not a link](

To create not a block, but an inline code span, use backticks:

Here is some inline `code`.

For more help see

This site uses Akismet to reduce spam. Learn how your comment data is processed.