
如何编辑WordPress代码 – HTML、CSS、PHP
_prime_post_caches ( $ids, $update_term_cache = true, $update_meta_cache = true )
prime_post_caches: 这个函数用来为后置数据预置缓存。它为一个文章ID列表预装了文章数据,以提高后来请求文章数据时的性能。
从给定的ID中添加任何不存在于缓存中的文章到缓存中。
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)", implode( ',', $non_cached_ids ) ) ); update_post_caches( $fresh_posts, 'any', $update_term_cache, $update_meta_cache ); } }