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

返回介绍

update_post_thumbnail_cache()

发布于 2017-09-11 字数1584 浏览 763 评论 0

update_post_thumbnail_cache( WP_Query $wp_query = null )

Update cache for thumbnails in the current loop.


描述


参数

$wp_query

(WP_Query)
(Optional)
A WP_Query instance. Defaults to the $wp_query global.

Default value: null


源代码

File: wp-includes/post-thumbnail-template.php

function update_post_thumbnail_cache( $wp_query = null ) {
	if ( ! $wp_query )
		$wp_query = $GLOBALS['wp_query'];

	if ( $wp_query->thumbnails_cached )
		return;

	$thumb_ids = array();
	foreach ( $wp_query->posts as $post ) {
		if ( $id = get_post_thumbnail_id( $post->ID ) )
			$thumb_ids[] = $id;
	}

	if ( ! empty ( $thumb_ids ) ) {
		_prime_post_caches( $thumb_ids, false, true );
	}

	$wp_query->thumbnails_cached = true;
}

更新日志

Version 描述
3.2.0 Introduced.

相关函数

Uses

  • wp-includes/post-thumbnail-template.php:
    get_post_thumbnail_id()
  • wp-includes/post.php:
    _prime_post_caches()

Used By

  • wp-includes/post-thumbnail-template.php:
    get_the_post_thumbnail()

User Contributed Notes

发布评论

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

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