update_posts_count

Update a blog's post count.

Description

update_posts_count( (string) $deprecated = '' ); 

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_site(). This function is called when posts are published or unpublished to make sure the count stays current.

Parameters (1)

0. $deprecated — Optional. (string) => ''
The deprecated.

Usage

  1. if ( !function_exists( 'update_posts_count' ) ) { 
  2. require_once ABSPATH . WPINC . '/ms-functions.php'; 
  3.  
  4. // The deprecated. 
  5. $deprecated = ''; 
  6.  
  7. // NOTICE! Understand what this does before running. 
  8. $result = update_posts_count($deprecated); 
  9.  

Defined (1)

The function is defined in the following location(s).

/wp-includes/ms-functions.php  
  1. function update_posts_count( $deprecated = '' ) { 
  2. global $wpdb; 
  3. update_option( 'post_count', (int) $wpdb->get_var( "SELECT COUNT(ID) FROM {$wpdb->posts} WHERE post_status = 'publish' and post_type = 'post'" ) );