wpseek.com
WordPress开发者和主题制作者的搜索引擎



update_post_cache › WordPress Function

Since1.5.1
已弃用n/a
update_post_cache ( $posts )
参数:
  • (WP_Post[]) $posts Array of post objects (passed by reference).
    Required: Yes
定义在:
文档:

Updates posts in cache.



源码

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