_prime_term_caches

Adds any terms from the given IDs to the cache that do not already exist in cache.

Description

_prime_term_caches( (array) $term_ids, (bool) $update_meta_cache = true ); 

Parameters (2)

0. $term_ids (array)
Array of term IDs.
1. $update_meta_cache — Optional. (bool) => true
Whether to update the meta cache. Default true.

Usage

  1. if ( !function_exists( '_prime_term_caches' ) ) { 
  2. require_once ABSPATH . WPINC . '/taxonomy.php'; 
  3.  
  4. // Array of term IDs. 
  5. $term_ids = array(); 
  6.  
  7. // Optional. Whether to update the meta cache. Default true. 
  8. $update_meta_cache = true; 
  9.  
  10. // NOTICE! Understand what this does before running. 
  11. $result = _prime_term_caches($term_ids, $update_meta_cache); 
  12.  

Defined (1)

The function is defined in the following location(s).

/wp-includes/taxonomy.php  
  1. function _prime_term_caches( $term_ids, $update_meta_cache = true ) { 
  2. global $wpdb; 
  3.  
  4. $non_cached_ids = _get_non_cached_ids( $term_ids, 'terms' ); 
  5. if ( ! empty( $non_cached_ids ) ) { 
  6. $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)", join( ", ", array_map( 'intval', $non_cached_ids ) ) ) ); 
  7.  
  8. update_term_cache( $fresh_terms, $update_meta_cache ); 
  9.  
  10. if ( $update_meta_cache ) { 
  11. update_termmeta_cache( $non_cached_ids );