_prime_term_caches

函式
_prime_term_caches ( $term_ids, $update_meta_cache = true )
引數
  • (array) $term_ids Array of term IDs.
    Required:
  • (bool) $update_meta_cache Optional. Whether to update the meta cache. Default true.
    Required:
    Default: true
定義位置
相關方法
_prime_site_caches_prime_post_caches_prime_network_caches_prime_comment_cachesupdate_term_cache
引入
4.6.0
棄用
-

_prime_term_caches: 該函式用於為給定的術語列表填充快取。它執行資料庫查詢以檢索術語列表,然後對結果進行快取以提高效能。

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

Plain text
Copy to clipboard
Open code in new window
EnlighterJS 3 Syntax Highlighter
function _prime_term_caches( $term_ids, $update_meta_cache = true ) {
global $wpdb;
$non_cached_ids = _get_non_cached_ids( $term_ids, 'terms' );
if ( ! empty( $non_cached_ids ) ) {
$fresh_terms = $wpdb->get_results( sprintf( "SELECT t.*, tt.* FROM $wpdb->terms AS t INNER JOIN $wpdb->term_taxonomy AS tt ON t.term_id = tt.term_id WHERE t.term_id IN (%s)", implode( ',', array_map( 'intval', $non_cached_ids ) ) ) );
update_term_cache( $fresh_terms );
if ( $update_meta_cache ) {
update_termmeta_cache( $non_cached_ids );
}
}
}
function _prime_term_caches( $term_ids, $update_meta_cache = true ) { global $wpdb; $non_cached_ids = _get_non_cached_ids( $term_ids, 'terms' ); if ( ! empty( $non_cached_ids ) ) { $fresh_terms = $wpdb->get_results( sprintf( "SELECT t.*, tt.* FROM $wpdb->terms AS t INNER JOIN $wpdb->term_taxonomy AS tt ON t.term_id = tt.term_id WHERE t.term_id IN (%s)", implode( ',', array_map( 'intval', $non_cached_ids ) ) ) ); update_term_cache( $fresh_terms ); if ( $update_meta_cache ) { update_termmeta_cache( $non_cached_ids ); } } }
function _prime_term_caches( $term_ids, $update_meta_cache = true ) {
	global $wpdb;

	$non_cached_ids = _get_non_cached_ids( $term_ids, 'terms' );
	if ( ! empty( $non_cached_ids ) ) {
		$fresh_terms = $wpdb->get_results( sprintf( "SELECT t.*, tt.* FROM $wpdb->terms AS t INNER JOIN $wpdb->term_taxonomy AS tt ON t.term_id = tt.term_id WHERE t.term_id IN (%s)", implode( ',', array_map( 'intval', $non_cached_ids ) ) ) );

		update_term_cache( $fresh_terms );

		if ( $update_meta_cache ) {
			update_termmeta_cache( $non_cached_ids );
		}
	}
}

常見問題

FAQs
檢視更多 >