wp_delete_attachment ( $post_id, $force_delete = false )
- (int) $post_id Attachment ID.
- (bool) $force_delete Optional. Whether to bypass trash and force deletion. Default false.
- (WP_Post|false|null) Post data on success, false or null on failure.
- Introduced in WordPress: 2.0.0
- Deprecated in WordPress: —
Trash or delete 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.