On this page
_update_posts_count_on_transition_post_status( string $new_status, string $old_status, WP_Post $post = null )
Handler for updating the current site’s posts count when a post status changes.
Parameters
$new_statusstring Required-
The status the post is changing to.
$old_statusstring Required-
The status the post is changing from.
$postWP_Post Optional-
Post object
Default:
null
Source
File: wp-includes/ms-blogs.php. View all references
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();
}
Related
Uses
| Uses | Description |
|---|---|
| get_post_type() wp-includes/post.php | Retrieves the post type of the current post or of a given post. |
| update_posts_count() wp-includes/ms-functions.php | Updates a blog’s post count. |
Changelog
© 2003–2022 WordPress Foundation
Licensed under the GNU GPLv2+ License.
https://developer.wordpress.org/reference/functions/_update_posts_count_on_transition_post_status