wp_delete_attachment
wp_delete_attachment ( $post_id, $force_delete = false )
Parameters:- (int) post_id Attachment ID.
- (bool) force_delete Optional. Whether to bypass Trash and force deletion. Default false.
Returns:- (WP_Post|false|null) Post data on success, false or null on failure.
Defined at: - Introduced in WordPress: 2.0.0
- Deprecated in WordPress: —
Description
Trashes or deletes an attachment.When an attachment is permanently deleted, the file will also be removed.
Deletion removes all post meta fields, taxonomy, comments, etc. associated
with the attachment (except the main post).
The attachment is moved to the Trash instead of permanently deleted unless Trash
for media is disabled, item is already in the Trash, or $force_delete is true.