返回介绍

_update_term_count_on_transition_post_status()

发布于 2017-09-11 13:38:25 字数 1898 浏览 1018 评论 0 收藏 0

Alert: This function’s access is marked private. This means it is not intended for use by plugin or theme developers, only in other core functions. It is listed here for completeness.

_update_term_count_on_transition_post_status( string $new_status,  string $old_status,  WP_Post $post )

Update the custom taxonomies’ term counts when a post’s status is changed.


description

For example, default posts term counts (for custom taxonomies) don’t include private / draft posts.


参数

$new_status

(string) (Required) New post status.

$old_status

(string) (Required) Old post status.

$post

(WP_Post) (Required) Post object.


源代码

File: wp-includes/post.php

function _update_term_count_on_transition_post_status( $new_status, $old_status, $post ) {
	// Update counts for the post's terms.
	foreach ( (array) get_object_taxonomies( $post->post_type ) as $taxonomy ) {
		$tt_ids = wp_get_object_terms( $post->ID, $taxonomy, array( 'fields' => 'tt_ids' ) );
		wp_update_term_count( $tt_ids, $taxonomy );
	}
}

更新日志

Versiondescription
3.3.0Introduced.

相关函数

Uses

  • wp-includes/taxonomy.php: wp_update_term_count()
  • wp-includes/taxonomy.php: wp_get_object_terms()
  • wp-includes/taxonomy.php: get_object_taxonomies()

User Contributed Notes

如果你对这篇内容有疑问,欢迎到本站社区发帖提问 参与讨论,获取更多帮助,或者扫码二维码加入 Web 技术交流群。

扫码二维码加入Web技术交流群

发布评论

需要 登录 才能够评论, 你可以免费 注册 一个本站的账号。
列表为空,暂无数据
    我们使用 Cookies 和其他技术来定制您的体验包括您的登录状态等。通过阅读我们的 隐私政策 了解更多相关信息。 单击 接受 或继续使用网站,即表示您同意使用 Cookies 和您的相关数据。
    原文