wpseek.com
WordPress开发者和主题制作者的搜索引擎



update_posts_count › WordPress Function

Since
已弃用n/a
update_posts_count ( $deprecated = '' )
参数:
  • (string) $deprecated Not used.
    Required: No
    默认: (empty)
定义在:
文档:
Change Log:
  • MU

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


源码

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