Return WP_Post from get_adjacent_post(). see #21309

git-svn-id: https://develop.svn.wordpress.org/trunk@21627 602fd350-edb4-49c9-b593-d223f7449a82
This commit is contained in:
Ryan Boren
2012-08-27 13:13:40 +00:00
parent 58e0fdfd7b
commit 62f9874a23

View File

@@ -1175,14 +1175,21 @@ function get_adjacent_post( $in_same_cat = false, $excluded_categories = '', $pr
$query = "SELECT p.* FROM $wpdb->posts AS p $join $where $sort";
$query_key = 'adjacent_post_' . md5($query);
$result = wp_cache_get($query_key, 'counts');
if ( false !== $result )
if ( false !== $result ) {
if ( is_object( $result ) )
$result = new WP_Post( $result );
return $result;
}
$result = $wpdb->get_row("SELECT p.* FROM $wpdb->posts AS p $join $where $sort");
if ( null === $result )
$result = '';
wp_cache_set($query_key, $result, 'counts');
if ( is_object( $result ) )
$result = new WP_Post( $result );
return $result;
}