From 82a2f2a426bb296387dc9bfb15aace3bc825611b Mon Sep 17 00:00:00 2001 From: Andrew Ozz Date: Fri, 20 Nov 2009 03:01:22 +0000 Subject: [PATCH] Limit wp_get_recent_posts() to real/live posts, props josephscott, fixes #11123 git-svn-id: https://develop.svn.wordpress.org/trunk@12237 602fd350-edb4-49c9-b593-d223f7449a82 --- wp-includes/post.php | 6 +++--- 1 file changed, 3 insertions(+), 3 deletions(-) diff --git a/wp-includes/post.php b/wp-includes/post.php index d25056e968..d74046f93d 100644 --- a/wp-includes/post.php +++ b/wp-includes/post.php @@ -1504,12 +1504,12 @@ function wp_get_recent_posts($num = 10) { // Set the limit clause, if we got a limit $num = (int) $num; - if ($num) { + if ( $num ) { $limit = "LIMIT $num"; } - $sql = "SELECT * FROM $wpdb->posts WHERE post_type = 'post' ORDER BY post_date DESC $limit"; - $result = $wpdb->get_results($sql,ARRAY_A); + $sql = "SELECT * FROM $wpdb->posts WHERE post_type = 'post' AND post_status IN ( 'draft', 'publish', 'future', 'pending', 'private' ) ORDER BY post_date DESC $limit"; + $result = $wpdb->get_results($sql, ARRAY_A); return $result ? $result : array(); }