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
This commit is contained in:
Andrew Ozz 2009-11-20 03:01:22 +00:00
parent 26a9029a82
commit 82a2f2a426

View File

@ -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();
}