WordPress at a glance
function is not described

_prime_term_caches() WP 4.6.0

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

This is an internal function for using it by WP core itself. It's not recommended to use this function in your code.

No Hooks.


null. Nothing.


_prime_term_caches( $term_ids, $update_meta_cache );
$term_ids(array) (required)
Array of term IDs.
Whether to update the meta cache.
Default: true


  • Global. wpdb. $wpdb WordPress database abstraction object.


Since 4.6.0 Introduced.

Code of _prime_term_caches() WP 5.7.2

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, $update_meta_cache );

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