update_post_cache()
Updates posts in cache.
No Hooks.
Return
null
. Nothing (null).
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. |
update_post_cache() update post cache code 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' ); }