On this page
_prime_post_caches( int[] $ids, bool $update_term_cache = true, bool $update_meta_cache = true )
Adds any posts from the given IDs to the cache that do not already exist in cache.
Description
See also
Parameters
$idsint[] Required-
ID list.
$update_term_cachebool Optional-
Whether to update the term cache.
Default:
true $update_meta_cachebool Optional-
Whether to update the meta cache.
Default:
true
Source
File: wp-includes/post.php. View all references
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 );
}
}
Related
Uses
| Uses | Description |
|---|---|
| _get_non_cached_ids() wp-includes/functions.php | Retrieves IDs that are not already present in the cache. |
| update_post_caches() wp-includes/post.php | Updates post, term, and metadata caches for a list of post objects. |
| wpdb::get_results() wp-includes/class-wpdb.php | Retrieves an entire SQL result set from the database (i.e., many rows). |
Used By
| Used By | Description |
|---|---|
| update_menu_item_cache() wp-includes/nav-menu.php | Updates post and term caches for all linked objects for a list of menu items. |
| update_post_parent_caches() wp-includes/post.php | Updates parent post caches for a list of post objects. |
| wp_filter_content_tags() wp-includes/media.php | Filters specific tags in post content and modifies their markup. |
| WP_Comment_Query::get_comments() wp-includes/class-wp-comment-query.php | Get a list of comments matching the query vars. |
| WP_Posts_List_Table::_display_rows_hierarchical() wp-admin/includes/class-wp-posts-list-table.php | |
| WP_Query::get_posts() wp-includes/class-wp-query.php | Retrieves an array of posts based on query variables. |
| WP_Widget_Recent_Comments::widget() wp-includes/widgets/class-wp-widget-recent-comments.php | Outputs the content for the current Recent Comments widget instance. |
| update_post_thumbnail_cache() wp-includes/post-thumbnail-template.php | Updates cache for thumbnails in the current loop. |
| get_pages() wp-includes/post.php | Retrieves an array of pages (or hierarchical post type items). |
Changelog
© 2003–2022 WordPress Foundation
Licensed under the GNU GPLv2+ License.
https://developer.wordpress.org/reference/functions/_prime_post_caches