delete_attachment

delete_attachment

Appears in: , , , , , , , , , , , , , , , , , , , , , , , , , , , , , , , , , , , , , , , , , , , , , , , , , , , , , , , , , , , , , , , , , , ,
Hook Type: action
See hook in action

See hook in core

Displaying hooks found in version: wordpress-6.6.2

do_action('delete_attachment') is found 1 times:

  • /wp-includes/post.php line 6433
    	 *
    	 * @param int     $post_id Attachment ID.
    	 * @param WP_Post $post    Post object.
    	 */
    	do_action( 'delete_attachment', $post_id, $post );
    
    	wp_delete_object_term_relationships( $post_id, array( 'category', 'post_tag' ) );
    	wp_delete_object_term_relationships( $post_id, get_object_taxonomies( $post->post_type ) );
    
    	// Delete all for any posts.
    	delete_metadata( 'post', null, '_thumbnail_id', $post_id, true );
    

See this hook used in plugins: