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



_update_posts_count_on_transition_post_status › WordPress Function

Since4.0.0
已弃用n/a
_update_posts_count_on_transition_post_status ( $new_status, $old_status, $post = null )
参数: (3)
  • (string) $new_status The status the post is changing to.
    Required: Yes
  • (string) $old_status The status the post is changing from.
    Required: Yes
  • (WP_Post) $post Post object
    Required: No
    默认: null
定义在:
文档:
Change Log:
  • 4.9.0

Handler for updating the current site's posts count when a post status changes.



源码

function _update_posts_count_on_transition_post_status( $new_status, $old_status, $post = null ) {
	if ( $new_status === $old_status ) {
		return;
	}

	if ( 'post' !== get_post_type( $post ) ) {
		return;
	}

	if ( 'publish' !== $new_status && 'publish' !== $old_status ) {
		return;
	}

	update_posts_count();
}