update_posts_count() - WordPress 函数参考中文文档

返回介绍

update_posts_count()

发布于 2017-09-11 字数1598 浏览 985 评论 0

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


参数

$deprecated

(string)
(Optional)
Not used.

Default value: ”


源代码

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

更新日志

Version 描述
MU Introduced.

相关函数

Uses

  • wp-includes/option.php:
    update_option()
  • wp-includes/wp-db.php:
    wpdb::get_var()

Used By

  • wp-includes/ms-blogs.php:
    _update_posts_count_on_delete()
  • wp-includes/ms-blogs.php:
    _update_posts_count_on_transition_post_status()

User Contributed Notes

发布评论

需要 登录 才能够评论, 你可以免费 注册 一个本站的账号。

目前还没有任何评论,快来抢沙发吧!