_update_posts_count_on_delete()WP 4.0.0

Handler for updating the current site's posts count when a post is deleted.

Internal function — this function is designed to be used by the kernel itself. It is not recommended to use this function in your code.

No Hooks.

Return

null. Nothing (null).

Usage

_update_posts_count_on_delete( $post_id, $post );
$post_id(int) (required)
Post ID.
$post(WP_Post) (required)
Post object.

Changelog

Since 4.0.0 Introduced.
Since 6.2.0 Added the $post parameter.

_update_posts_count_on_delete() code WP 6.6

function _update_posts_count_on_delete( $post_id, $post ) {
	if ( ! $post || 'publish' !== $post->post_status || 'post' !== $post->post_type ) {
		return;
	}

	update_posts_count();
}