Advertisements

update_post_thumbnail_cache

Definition:
function update_post_thumbnail_cache() {}

Update cache for thumbnails in the current loop

Source code

function update_post_thumbnail_cache() {

	global $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 ) ) {

		get_posts( array(

				'update_post_term_cache' => false,

				'include' => $thumb_ids,

				'post_type' => 'attachment',

				'post_status' => 'inherit',

				'nopaging' => true

		) );

	}



	$wp_query->thumbnails_cached = true;

}

14820

Advertisements

No comments yet... Be the first to leave a reply!

Leave a Reply

Fill in your details below or click an icon to log in:

WordPress.com Logo

You are commenting using your WordPress.com account. Log Out / Change )

Twitter picture

You are commenting using your Twitter account. Log Out / Change )

Facebook photo

You are commenting using your Facebook account. Log Out / Change )

Google+ photo

You are commenting using your Google+ account. Log Out / Change )

Connecting to %s

%d bloggers like this: