Fires immediately before a post is deleted from the database.
Parameters
$post_idint- Post ID.
$postWP_Post- Post object.
Source
do_action( 'delete_post', $post_id, $post );
| CARVIEW |
Fires immediately before a post is deleted from the database.
$post_idint$postWP_PostTake note, by the time the hook triggers, the post comments and metadata would have already been deleted. Use the before_delete_post hook to catch post deletion before that.
do_action( 'delete_post', $post_id, $post );
| Used by | Description |
|---|---|
wp_delete_attachment()wp-includes/post.php | Trashes or deletes an attachment. |
wp_delete_post()wp-includes/post.php | Trashes or deletes a post or page. |
You must log in before being able to contribute a note or feedback.
Let’s suppose you have a plugin that, for one reason or another, stores its own post metadata in a separate database table called codex_postmeta. One of the ways you can achieve synchronization is to be made aware when a post is deleted so that you can replicate the changes yourself.