WordPress Version: 6.1
/**
* Updates posts in cache.
*
* @since 1.5.1
*
* @param WP_Post[] $posts Array of post objects (passed by reference).
*/
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');
}