wpseek.com
A WordPress-centric search engine for devs and theme authors



update_post_cache › WordPress Function

Since1.5.1
Deprecatedn/a
update_post_cache ( $posts )
Parameters:
  • (WP_Post[]) $posts Array of post objects (passed by reference).
    Required: Yes
Defined at:
Codex:

Updates posts in cache.



Source

function update_post_cache( &$posts ) {
	if ( ! $posts ) {
		return;
	}

	$data = array();
	foreach ( $posts as $post ) {
		if ( empty( $post->filter ) || 'raw' !== $post->filter ) {
			$post = sanitize_post( $post, 'raw' );
		}
		$data[ $post->ID ] = $post;
	}
	wp_cache_add_multiple( $data, 'posts' );
}