_prime_post_caches() - WordPress 函数参考中文文档

返回介绍

_prime_post_caches()

发布于 2017-09-11 字数 2527 浏览 872 评论 0

Alert: This function’s access is marked private. This means it is not intended for use by plugin or theme developers, only in other core functions. It is listed here for completeness. Use update_post_caches() instead.

_prime_post_caches( array $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


描述


参数

$ids

(array)
(Required)
ID list.

$update_term_cache

(bool)
(Optional)
Whether to update the term cache.

Default value: true

$update_meta_cache

(bool)
(Optional)
Whether to update the meta cache.

Default value: true


源代码

File: wp-includes/post.php

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)", join( ",", $non_cached_ids ) ) );

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

更新日志

Version 描述
3.4.0 Introduced.

相关函数

Uses

  • wp-includes/functions.php:
    _get_non_cached_ids()
  • wp-includes/post.php:
    update_post_caches()
  • wp-includes/wp-db.php:
    wpdb::get_results()

Used By

  • wp-includes/class-wp-comment-query.php:
    WP_Comment_Query::get_comments()
  • wp-admin/includes/class-wp-posts-list-table.php:
    WP_Posts_List_Table::_display_rows_hierarchical()
  • wp-includes/class-wp-query.php:
    WP_Query::get_posts()
  • wp-includes/widgets/class-wp-widget-recent-comments.php:
    WP_Widget_Recent_Comments::widget()
  • wp-includes/post-thumbnail-template.php:
    update_post_thumbnail_cache()

User Contributed Notes

发布评论

需要 登录 才能够评论, 你可以免费 注册 一个本站的账号。

目前还没有任何评论,快来抢沙发吧!