返回介绍

_prime_post_caches()

发布于 2017-09-11 13:34:06 字数 2528 浏览 958 评论 0 收藏 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


description


参数

$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 );
	}
}

更新日志

Versiondescription
3.4.0Introduced.

相关函数

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

如果你对这篇内容有疑问,欢迎到本站社区发帖提问 参与讨论,获取更多帮助,或者扫码二维码加入 Web 技术交流群。

扫码二维码加入Web技术交流群

发布评论

需要 登录 才能够评论, 你可以免费 注册 一个本站的账号。
列表为空,暂无数据
    我们使用 Cookies 和其他技术来定制您的体验包括您的登录状态等。通过阅读我们的 隐私政策 了解更多相关信息。 单击 接受 或继续使用网站,即表示您同意使用 Cookies 和您的相关数据。
    原文