Return WP_Post from get_adjacent_post(). see #21309

git-svn-id: http://core.svn.wordpress.org/trunk@21627 1a063a9b-81f0-0310-95a4-ce76da25c4cd
This commit is contained in:
Ryan Boren 2012-08-27 13:13:40 +00:00
parent afd493abe9
commit af91b41af3
1 changed files with 8 additions and 1 deletions

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;
}