WordPress.org

Make WordPress Core

Ticket #12989: 12989.diff

File 12989.diff, 1.3 KB (added by ryan, 4 years ago)
  • wp-includes/post.php

     
    40114011 * @uses update_postmeta_cache() 
    40124012 * 
    40134013 * @param array $posts Array of Post objects 
     4014 * @param string $post_type The post type of the posts in $posts 
    40144015 */ 
    4015 function update_post_caches(&$posts) { 
     4016function update_post_caches(&$posts, $post_type = 'post') { 
    40164017        // No point in doing all this work if we didn't match any posts. 
    40174018        if ( !$posts ) 
    40184019                return; 
     
    40244025        for ($i = 0; $i < count($posts); $i++) 
    40254026                $post_ids[] = $posts[$i]->ID; 
    40264027 
    4027         update_object_term_cache($post_ids, 'post'); 
     4028        if ( empty($post_type) ) 
     4029                $post_type = 'post'; 
    40284030 
     4031        if ( !is_array($post_type) ) 
     4032                update_object_term_cache($post_ids, $post_type); 
     4033 
    40294034        update_postmeta_cache($post_ids); 
    40304035} 
    40314036 
  • wp-includes/query.php

     
    24972497                        $this->posts[$i] = sanitize_post($this->posts[$i], 'raw'); 
    24982498                } 
    24992499 
    2500                 update_post_caches($this->posts); 
     2500                update_post_caches($this->posts, $post_type); 
    25012501 
    25022502                if ($this->post_count > 0) { 
    25032503                        $this->post = $this->posts[0];