update_posts_count() WordPress Function

The update_posts_count() function is used to update the number of posts a user has made. This function is used primarily in the admin area when a user is deleted.

update_posts_count( string $deprecated = '' ) #

Updates a blog’s post count.


Description

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.


Top ↑

Parameters

$deprecated

(string)(Optional)Not used.

Default value: ''


Top ↑

Source

File: wp-includes/ms-functions.php

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'" ) );
}


Top ↑

Changelog

Changelog
VersionDescription
MU (3.0.0)Introduced.

The content displayed on this page has been created in part by processing WordPress source code files which are made available under the GPLv2 (or a later version) license by theĀ Free Software Foundation. In addition to this, the content includes user-written examples and information. All material is subject to review and curation by the WPPaste.com community.

Show More
Show More