update_post_cache( WP_Post[] $posts )

In this article

Updates posts in cache.

Parameters

$postsWP_Post[]required
Array of post objects (passed by reference).

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' );
}

Changelog

VersionDescription
1.5.1Introduced.

User Contributed Notes

You must log in before being able to contribute a note or feedback.