update_term_cache

Updates Terms to Taxonomy in cache.

Description

update_term_cache( (array) $terms, (string) $taxonomy = '' ); 

Parameters (2)

0. $terms (array)
List of term objects to change.
1. $taxonomy — Optional. (string) => ''
Update Term to this taxonomy in cache. Default empty.

Usage

  1. if ( !function_exists( 'update_term_cache' ) ) { 
  2. require_once ABSPATH . WPINC . '/taxonomy.php'; 
  3.  
  4. // List of term objects to change. 
  5. $terms = array(); 
  6.  
  7. // Optional. Update Term to this taxonomy in cache. Default empty. 
  8. $taxonomy = ''; 
  9.  
  10. // NOTICE! Understand what this does before running. 
  11. $result = update_term_cache($terms, $taxonomy); 
  12.  

Defined (1)

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

/wp-includes/taxonomy.php  
  1. function update_term_cache( $terms, $taxonomy = '' ) { 
  2. foreach ( (array) $terms as $term ) { 
  3. // Create a copy in case the array was passed by reference. 
  4. $_term = clone $term; 
  5.  
  6. // Object ID should not be cached. 
  7. unset( $_term->object_id ); 
  8.  
  9. wp_cache_add( $term->term_id, $_term, 'terms' );