delete_post action-hookWP 1.2.0

Fires immediately before a post is deleted from the database.

Usage

add_action( 'delete_post', 'wp_kama_delete_post_action', 10, 2 );

/**
 * Function for `delete_post` action-hook.
 * 
 * @param int     $postid Post ID.
 * @param WP_Post $post   Post object.
 *
 * @return void
 */
function wp_kama_delete_post_action( $postid, $post ){

	// action...
}
$postid(int)
Post ID.
$post(WP_Post)
Post object.

Changelog

Since 1.2.0 Introduced.
Since 5.5.0 Added the $post parameter.

Where the hook is called

wp_delete_post()
delete_post
wp_delete_attachment()
delete_post
wp-includes/post.php 3443
do_action( 'delete_post', $postid, $post );
wp-includes/post.php 6399
do_action( 'delete_post', $post_id, $post );

Where the hook is used in WordPress

wp-includes/blocks/calendar.php 151
add_action( 'delete_post', 'block_core_calendar_update_has_published_post_on_delete' );
wp-includes/default-filters.php 434
add_action( 'delete_post', '_wp_delete_post_menu_item' );
wp-includes/default-filters.php 437
add_action( 'delete_post', '_wp_delete_customize_changeset_dependent_auto_drafts' );
wp-includes/default-filters.php 528
add_action( 'delete_post', 'delete_get_calendar_cache' );
wp-includes/ms-default-filters.php 80
add_action( 'delete_post', '_update_blog_date_on_post_delete' );
wp-includes/nav-menu.php 1141
remove_action( 'delete_post', '_wp_delete_customize_changeset_dependent_auto_drafts' );
wp-includes/nav-menu.php 1153
add_action( 'delete_post', '_wp_delete_customize_changeset_dependent_auto_drafts' );