update_post_cache() WP 1.5.1
Updates posts in cache.
No Hooks.
Return
null
. Null. Nothing.
Usage
update_post_cache( $posts );
- $posts(WP_Post[]) (required) (passed by reference — &)
- Array of post objects (passed by reference).
Changelog
Since 1.5.1 | Introduced. |
Code of update_post_cache() update post cache WP 5.7.1
function update_post_cache( &$posts ) {
if ( ! $posts ) {
return;
}
foreach ( $posts as $post ) {
wp_cache_add( $post->ID, $post, 'posts' );
}
}