
利用Query Monitor插件调试WordPress并提高网站性能
_prime_term_caches ( $term_ids, $update_meta_cache = true )
_prime_term_caches: 该函数用于为给定的术语列表填充缓存。它执行数据库查询以检索术语列表,然后对结果进行缓存以提高性能。
从给定的ID中添加任何不存在于缓存中的术语到缓存中。
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 ); } } }