How to Delete an Attachment in WordPress
WordPress provides an easy way to delete attachments.
Background
WordPress creates a new attachment each time we upload a file to the Media Library. Attachments are instances of the 'attachment'
built-in post type. They contain metadata pulled from the file, such as file name and file size, and other fields like caption and description.
The uploaded file is stored in the wp-content/uploads folder by default. The attachment data is stored in the tables wp_posts and wp_postmeta. Deleting an attachment means deleting the file and all related records.
Steps
Follow these steps to delete an attachment in WordPress.
Step 1: Navigate to the Media Library.
Step 2: Click Delete Permanently in the action links for the target element.
Step 3: A confirmation window will appear. Click OK.
Further reading
I recommend the other tutorials in this series to learn more about managing attachments in WordPress.
Comments