update_post_cache

Updates posts in cache.

Description

update_post_cache( (array) &$posts ); 

Parameters (1)

0. $posts (array) => &$posts
Array of post objects, passed by reference.

Usage

  1. if ( !function_exists( 'update_post_cache' ) ) { 
  2. require_once ABSPATH . WPINC . '/post.php'; 
  3.  
  4. // Array of post objects, passed by reference. 
  5. $posts = array(); 
  6.  
  7. // NOTICE! Understand what this does before running. 
  8. $result = update_post_cache($posts); 
  9.  

Defined (1)

The function is defined in the following location(s).

/wp-includes/post.php  
  1. function update_post_cache( &$posts ) { 
  2. if ( ! $posts ) 
  3. return; 
  4.  
  5. foreach ( $posts as $post ) 
  6. wp_cache_add( $post->ID, $post, 'posts' );