Action hook 'delete_post_{$post->post_type}'

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

View Source

delete_post_{$post->post_type}

Action Hook
Description
Fires immediately before a post is deleted from the database. The dynamic portion of the hook name, `$post->post_type`, refers to the post type slug.

Hook Information

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

Hook Parameters

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

Usage Examples

Basic Usage
<?php
// Hook into delete_post_{$post->post_type}
add_action('delete_post_{$post->post_type}', 'my_custom_function', 10, 2);

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

Source Code Context

wp-includes/post.php:3822 - How this hook is used in WordPress core
<?php
3817  	 * @since 6.6.0
3818  	 *
3819  	 * @param int     $post_id Post ID.
3820  	 * @param WP_Post $post    Post object.
3821  	 */
3822  	do_action( "delete_post_{$post->post_type}", $post_id, $post );
3823  
3824  	/**
3825  	 * Fires immediately before a post is deleted from the database.
3826  	 *
3827  	 * @since 1.2.0

PHP Documentation

<?php
/**
	 * Fires immediately before a post is deleted from the database.
	 *
	 * The dynamic portion of the hook name, `$post->post_type`, refers to
	 * the post type slug.
	 *
	 * @since 6.6.0
	 *
	 * @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.