WordPress.org

Make WordPress Core

Ticket #22061: 22061.diff

File 22061.diff, 1.1 KB (added by wonderboymusic, 6 years ago)
  • query.php

     
    27722772                if ( !$q['suppress_filters'] )
    27732773                        $this->posts = apply_filters_ref_array('the_posts', array( $this->posts, &$this ) );
    27742774
    2775                 $this->post_count = count( $this->posts );
    2776 
    27772775                // Ensure that any posts added/modified via one of the filters above are
    27782776                // of the type WP_Post and are filtered.
    2779                 if ( $this->posts )
     2777                if ( $this->posts ) {
     2778                        $this->post_count = count( $this->posts );
     2779                       
    27802780                        $this->posts = array_map( 'get_post', $this->posts );
    27812781
    2782                 if ( $q['cache_results'] )
    2783                         update_post_caches($this->posts, $post_type, $q['update_post_term_cache'], $q['update_post_meta_cache']);
     2782                        if ( $q['cache_results'] )
     2783                                update_post_caches($this->posts, $post_type, $q['update_post_term_cache'], $q['update_post_meta_cache']);
    27842784
    2785                 if ( $this->post_count > 0 ) {
    2786                         $this->post = $this->posts[0];
     2785                        $this->post = reset( $this->posts );                   
     2786                } else {
     2787                        $this->post_count = 0;
     2788                        $this->posts = array();
    27872789                }
    27882790
    27892791                return $this->posts;