_update_posts_count_on_delete()
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.
Returns
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() update posts count on delete code WP 6.8.1
function _update_posts_count_on_delete( $post_id, $post ) { if ( ! $post || 'publish' !== $post->post_status || 'post' !== $post->post_type ) { return; } update_posts_count(); }