Delete media
wp_delete_mediaPermanently deletes a WordPress media library attachment and its metadata, server file, and image sizes; it also removes the file as a featured image. No trash recovery.
Instructions
Delete one file of the media library (attachment) for good: its entry and metadata are removed, and WordPress deletes the file and its image sizes on the server (a file the server does not let it delete stays, without an error). The media library has no trash here. It is removed as featured image wherever it was one; posts that embed or link it keep its old URL. Needs the right to delete that file. Returns {deleted: true, id}; an id that no longer exists returns a not-found error. Posts and pages are deleted with wp_delete_post.
Input Schema
| Name | Required | Description | Default |
|---|---|---|---|
| id | Yes | Attachment id of the file to delete. |