将给定ID中的任何帖子添加到缓存中尚不存在的缓存中
原型
_prime_post_caches( array $ids, bool $update_term_cache = true, bool $update_meta_cache = true )
参数
$ids
(array)
(Required)
ID列表。
$update_term_cache
(bool)
(Optional)
是否更新术语缓存。
$update_meta_cache
(bool)
(Optional)
是否更新元缓存。
源文件
路径:wp-includes/post.php
<?php
...
function _prime_post_caches( $ids, $update_term_cache = true, $update_meta_cache = true ) {
global $wpdb;
$non_cached_ids = _get_non_cached_ids( $ids, 'posts' );
if ( !empty( $non_cached_ids ) ) {
$fresh_posts = $wpdb->get_results( sprintf( "SELECT $wpdb->posts.* FROM $wpdb->posts WHERE ID IN (%s)", join( ",", $non_cached_ids ) ) );
update_post_caches( $fresh_posts, 'any', $update_term_cache, $update_meta_cache );
}
}
...
?>
其他
英文文档:https://developer.wordpress.org/reference/functions/_prime_post_caches/