_prime_post_caches

函式
_prime_post_caches ( $ids, $update_term_cache = true, $update_meta_cache = true )
引數
  • (int[]) $ids ID list.
    Required:
  • (bool) $update_term_cache Optional. Whether to update the term cache. Default true.
    Required:
    Default: true
  • (bool) $update_meta_cache Optional. Whether to update the meta cache. Default true.
    Required:
    Default: true
相關
  • update_post_caches()
定義位置
相關方法
_prime_site_caches_prime_term_caches_prime_comment_cachesupdate_post_caches_prime_network_caches
引入
3.4.0
棄用
-

prime_post_caches: 這個函式用來為後置資料預置快取。它為一個文章ID列表預裝了文章資料,以提高後來請求文章資料時的效能。

從給定的ID中新增任何不存在於快取中的文章到快取中。

Plain text
Copy to clipboard
Open code in new window
EnlighterJS 3 Syntax Highlighter
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 );
}
}
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 ); } }
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 );
	}
}

常見問題

FAQs
檢視更多 >