On this page
update_post_cache( WP_Post[] $posts )
Updates posts in cache.
Parameters
$postsWP_Post[] Required-
Array of post objects (passed by reference).
Source
File: wp-includes/post.php. View all references
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' );
}
Related
Uses
| Uses | Description |
|---|---|
| wp_cache_add_multiple() wp-includes/cache.php | Adds multiple values to the cache in one call. |
| sanitize_post() wp-includes/post.php | Sanitizes every post field. |
Used By
| Used By | Description |
|---|---|
| get_children() wp-includes/post.php | Retrieves all children of the post parent ID. |
| update_page_cache() wp-includes/deprecated.php | Alias of update_post_cache() . |
| update_post_caches() wp-includes/post.php | Updates post, term, and metadata caches for a list of post objects. |
| get_pages() wp-includes/post.php | Retrieves an array of pages (or hierarchical post type items). |
Changelog
| Version | Description |
|---|---|
| 1.5.1 | Introduced. |
© 2003–2022 WordPress Foundation
Licensed under the GNU GPLv2+ License.
https://developer.wordpress.org/reference/functions/update_post_cache