Make WordPress Core


Ignore:
Timestamp:
04/29/2010 08:43:59 PM (14 years ago)
Author:
nacin
Message:

Update object term cache for custom post types. props scribu, fixes #12989.

File:
1 edited

Legend:

Unmodified
Added
Removed
  • trunk/wp-includes/post.php

    r14295 r14310  
    39833983 *
    39843984 * @param array $posts Array of Post objects
    3985  */
    3986 function update_post_caches(&$posts) {
     3985 * @param string $post_type The post type of the posts in $posts
     3986 */
     3987function update_post_caches(&$posts, $post_type = 'post') {
    39873988    // No point in doing all this work if we didn't match any posts.
    39883989    if ( !$posts )
     
    39923993
    39933994    $post_ids = array();
    3994 
    3995     for ($i = 0; $i < count($posts); $i++)
    3996         $post_ids[] = $posts[$i]->ID;
    3997 
    3998     update_object_term_cache($post_ids, 'post');
     3995    foreach ( $posts as $post )
     3996        $post_ids[] = $post->ID;
     3997
     3998    if ( empty($post_type) )
     3999        $post_type = 'post';
     4000
     4001    if ( !is_array($post_type) && 'any' != $post_type )
     4002        update_object_term_cache($post_ids, $post_type);
    39994003
    40004004    update_postmeta_cache($post_ids);
Note: See TracChangeset for help on using the changeset viewer.