update_post_caches

Definition:
function update_post_caches(&$posts, $post_type = 'post', $update_term_cache = true, $update_meta_cache = true) {}

Call major cache updating functions for list of Post objects.

Parameters

  • array $posts: Array of Post objects
  • string $post_type: The post type of the posts in $posts. Default is ‘post’.
  • bool $update_term_cache: Whether to update the term cache. Default is true.
  • bool $update_meta_cache: Whether to update the meta cache. Default is true.
  • &$posts

Source code

function update_post_caches(&$posts, $post_type = 'post', $update_term_cache = true, $update_meta_cache = true) {

	// No point in doing all this work if we didn't match any posts.

	if ( !$posts )

		return;



	update_post_cache($posts);



	$post_ids = array();

	foreach ( $posts as $post )

		$post_ids[] = $post->ID;



	if ( empty($post_type) )

		$post_type = 'post';



	if ( $update_term_cache ) {

		if ( is_array($post_type) ) {

			$ptypes = $post_type;

		} elseif ( 'any' == $post_type ) {

			// Just use the post_types in the supplied posts.

			foreach ( $posts as $post )

				$ptypes[] = $post->post_type;

			$ptypes = array_unique($ptypes);

		} else {

			$ptypes = array($post_type);

		}



		if ( ! empty($ptypes) )

			update_object_term_cache($post_ids, $ptypes);

	}



	if ( $update_meta_cache )

		update_postmeta_cache($post_ids);

}

3197

update_post_cache

Definition:
function update_post_cache(&$posts) {}

Updates posts in cache.

Parameters

  • array $posts: Array of post objects
  • &$posts

Source code

function update_post_cache(&$posts) {

	if ( !$posts )

		return;



	foreach ( $posts as $post )

		wp_cache_add($post->ID, $post, 'posts');

}

3195

update_posts_count

Definition:
function update_posts_count( $deprecated = '' ) {}

Update a blog’s post count.
WordPress MS stores a blog’s post count as an option so as to avoid extraneous COUNTs when a blog’s details are fetched with get_blog_details(). This function is called when posts are published to make sure the count stays current.

Parameters

  • $deprecated

Source code

function update_posts_count( $deprecated = '' ) {

	global $wpdb;

	update_option( 'post_count', (int) $wpdb->get_var( "SELECT COUNT(ID) FROM {$wpdb->posts} WHERE post_status = 'publish' and post_type = 'post'" ) );

3193