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:
parent
26a9029a82
commit
82a2f2a426
@ -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();
|
||||
}
|
||||
|
Loading…
Reference in New Issue
Block a user