update_post_cache()WP 1.5.1

Updates posts in cache.

Хуков нет.

Возвращает

null. Ничего (null).

Использование

update_post_cache( $posts );
$posts(WP_Post[]) (обязательный) (передается по ссылке — &)
Array of post objects (passed by reference).

Список изменений

С версии 1.5.1 Введена.

Код update_post_cache() WP 6.5.2

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