WordPress at a glance
function is not described

_prime_post_caches() WP 3.4.0

Adds any posts 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_post_caches( $ids, $update_term_cache, $update_meta_cache );
$ids(array) (required)
ID list.
Whether to update the term cache.
Default: true
Whether to update the meta cache.
Default: true


  • See: update_post_caches()
  • Global. wpdb. $wpdb WordPress database abstraction object.


Since 3.4.0 Introduced.

Code of _prime_post_caches() WP 5.7

function _prime_post_caches( $ids, $update_term_cache = true, $update_meta_cache = true ) {
	global $wpdb;

	$non_cached_ids = _get_non_cached_ids( $ids, 'posts' );
	if ( ! empty( $non_cached_ids ) ) {
		$fresh_posts = $wpdb->get_results( sprintf( "SELECT $wpdb->posts.* FROM $wpdb->posts WHERE ID IN (%s)", implode( ',', $non_cached_ids ) ) );

		update_post_caches( $fresh_posts, 'any', $update_term_cache, $update_meta_cache );