Action hook 'after_delete_post'

in WP Core File wp-includes/post.php at line 3885

View Source

after_delete_post

Action Hook
Description
Fires after a post is deleted, at the conclusion of wp_delete_post().

Hook Information

File Location wp-includes/post.php View on GitHub
Hook Type Action
Line Number 3885

Hook Parameters

Type Name Description
int $post_id Post ID.
WP_Post $post Post object.

Usage Examples

Basic Usage
<?php
// Hook into after_delete_post
add_action('after_delete_post', 'my_custom_function', 10, 2);

function my_custom_function($post_id, $post) {
    // Your custom code here
}

Source Code Context

wp-includes/post.php:3885 - How this hook is used in WordPress core
<?php
3880  	 * @see wp_delete_post()
3881  	 *
3882  	 * @param int     $post_id Post ID.
3883  	 * @param WP_Post $post    Post object.
3884  	 */
3885  	do_action( 'after_delete_post', $post_id, $post );
3886  
3887  	return $post;
3888  }
3889  
3890  /**

PHP Documentation

<?php
/**
	 * Fires after a post is deleted, at the conclusion of wp_delete_post().
	 *
	 * @since 3.2.0
	 * @since 5.5.0 Added the `$post` parameter.
	 *
	 * @see wp_delete_post()
	 *
	 * @param int     $post_id Post ID.
	 * @param WP_Post $post    Post object.
	 */
Quick Info
  • Hook Type: Action
  • Parameters: 2
  • File: wp-includes/post.php
Related Hooks

Related hooks will be displayed here in future updates.