From 5301d79a9739435cd13a72f76ffd65405e96b471 Mon Sep 17 00:00:00 2001 From: Mark Jaquith Date: Mon, 7 Dec 2009 18:09:11 +0000 Subject: [PATCH] Do not display comments on non-public posts in comments widget. props Denis-de-Bernardy. fixes #9211 git-svn-id: https://develop.svn.wordpress.org/trunk@12333 602fd350-edb4-49c9-b593-d223f7449a82 --- wp-includes/default-widgets.php | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/wp-includes/default-widgets.php b/wp-includes/default-widgets.php index d5c4e39ae3..6f9d16b51a 100644 --- a/wp-includes/default-widgets.php +++ b/wp-includes/default-widgets.php @@ -634,7 +634,7 @@ class WP_Widget_Recent_Comments extends WP_Widget { $number = 15; if ( !$comments = wp_cache_get( 'recent_comments', 'widget' ) ) { - $comments = $wpdb->get_results("SELECT * FROM $wpdb->comments WHERE comment_approved = '1' ORDER BY comment_date_gmt DESC LIMIT 15"); + $comments = $wpdb->get_results("SELECT $wpdb->comments.* FROM $wpdb->comments JOIN $wpdb->posts ON $wpdb->posts.ID = $wpdb->comments.comment_post_ID WHERE comment_approved = '1' AND post_status = 'publish' ORDER BY comment_date_gmt DESC LIMIT 15"); wp_cache_add( 'recent_comments', $comments, 'widget' ); }