update_term_cache
Updates Terms to Taxonomy in cache.
Description
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
if ( !function_exists( 'update_term_cache' ) ) { require_once ABSPATH . WPINC . '/taxonomy.php'; } // List of term objects to change. $terms = array(); // Optional. Update Term to this taxonomy in cache. Default empty. $taxonomy = ''; // NOTICE! Understand what this does before running. $result = update_term_cache($terms, $taxonomy);
Defined (1)
The function is defined in the following location(s).
- /wp-includes/taxonomy.php
- function update_term_cache( $terms, $taxonomy = '' ) {
- foreach ( (array) $terms as $term ) {
- // Create a copy in case the array was passed by reference.
- $_term = clone $term;
- // Object ID should not be cached.
- unset( $_term->object_id );
- wp_cache_add( $term->term_id, $_term, 'terms' );
- }
- }