If $this->posts is empty, don't do stuff to it.
Props wonderboymusic fixes #22061 git-svn-id: http://core.svn.wordpress.org/trunk@22465 1a063a9b-81f0-0310-95a4-ce76da25c4cd
This commit is contained in:
parent
c67a081816
commit
7cc32c3990
|
@ -2770,18 +2770,20 @@ class WP_Query {
|
||||||
if ( !$q['suppress_filters'] )
|
if ( !$q['suppress_filters'] )
|
||||||
$this->posts = apply_filters_ref_array('the_posts', array( $this->posts, &$this ) );
|
$this->posts = apply_filters_ref_array('the_posts', array( $this->posts, &$this ) );
|
||||||
|
|
||||||
$this->post_count = count( $this->posts );
|
|
||||||
|
|
||||||
// Ensure that any posts added/modified via one of the filters above are
|
// Ensure that any posts added/modified via one of the filters above are
|
||||||
// of the type WP_Post and are filtered.
|
// of the type WP_Post and are filtered.
|
||||||
if ( $this->posts )
|
if ( $this->posts ) {
|
||||||
|
$this->post_count = count( $this->posts );
|
||||||
|
|
||||||
$this->posts = array_map( 'get_post', $this->posts );
|
$this->posts = array_map( 'get_post', $this->posts );
|
||||||
|
|
||||||
if ( $q['cache_results'] )
|
if ( $q['cache_results'] )
|
||||||
update_post_caches($this->posts, $post_type, $q['update_post_term_cache'], $q['update_post_meta_cache']);
|
update_post_caches($this->posts, $post_type, $q['update_post_term_cache'], $q['update_post_meta_cache']);
|
||||||
|
|
||||||
if ( $this->post_count > 0 ) {
|
$this->post = reset( $this->posts );
|
||||||
$this->post = $this->posts[0];
|
} else {
|
||||||
|
$this->post_count = 0;
|
||||||
|
$this->posts = array();
|
||||||
}
|
}
|
||||||
|
|
||||||
return $this->posts;
|
return $this->posts;
|
||||||
|
|
Loading…
Reference in New Issue