update_posts_count()
update_posts_count( string $deprecated = ” ) 更新博客的帖子数。 …
update_posts_count( string $deprecated = ” )
更新博客的帖子数。
Update a blog’s post count.
目录锚点:#说明#参数#源码
说明(Description)
WordPress MS将博客的文章计数存储为一个选项,以避免在使用get_site()获取博客详细信息时出现额外的计数。在发布或取消发布帖子时调用此函数,以确保计数保持当前状态。
参数(Parameters)
| 参数 | 类型 | 说明 |
|---|---|---|
| $deprecated | (string) | 未使用。 |
源码(Source)
/**
* 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 or unpublished to make sure the count stays current.
*
* @since MU
*
* @global wpdb $wpdb
*/
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'" ) );
}| 更新版本 | 源码位置 | 使用 | 被使用 |
|---|---|---|---|
| MU (3.0.0) | wp-includes/ms-functions.php | 20 | 20 |
类别:WordPress 函数手册、
本文收集自互联网,转载请注明来源。
如有侵权,请联系 wper_net@163.com 删除。

还没有任何评论,赶紧来占个楼吧!