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

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

View Source

deleted_post_{$post->post_type}

Action Hook
Description
Fires immediately after 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 3851

Hook Parameters

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

Usage Examples

Basic Usage
<?php
// Hook into deleted_post_{$post->post_type}
add_action('deleted_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:3851 - How this hook is used in WordPress core
<?php
3846  	 * @since 6.6.0
3847  	 *
3848  	 * @param int     $post_id Post ID.
3849  	 * @param WP_Post $post    Post object.
3850  	 */
3851  	do_action( "deleted_post_{$post->post_type}", $post_id, $post );
3852  
3853  	/**
3854  	 * Fires immediately after a post is deleted from the database.
3855  	 *
3856  	 * @since 2.2.0

PHP Documentation

<?php
/**
	 * Fires immediately after 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.