delete_attachment
Fires before an attachment is deleted, at the start of wp_delete_attachment().
Usage
add_action( 'delete_attachment', 'wp_kama_delete_attachment_action', 10, 2 );
/**
* Function for `delete_attachment` action-hook.
*
* @param int $post_id Attachment ID.
* @param WP_Post $post Post object.
*
* @return void
*/
function wp_kama_delete_attachment_action( $post_id, $post ){
// action...
}
- $post_id(int)
- Attachment ID.
- $post(WP_Post)
- Post object.
Changelog
| Since 2.0.0 | Introduced. |
| Since 5.5.0 | Added the $post parameter. |
Where the hook is called
wp-includes/post.php 6740
do_action( 'delete_attachment', $post_id, $post );
Where the hook is used in WordPress
wp-admin/includes/class-wp-site-icon.php 73
add_action( 'delete_attachment', array( $this, 'delete_attachment_data' ) );
wp-includes/default-filters.php 558
add_action( 'delete_attachment', '_delete_attachment_theme_mod' );