-
-
Save stefanRepac/d0ad66cff63ecf0bc1d0f5dc881d9dd3 to your computer and use it in GitHub Desktop.
Using FTP/SSH & Database | |
This method allows you to delete all items in your media library at once. Be sure to backup your database prior to doing this. | |
Each file in your media library has one row in the `wp_posts` table and two rows in the `wp_postmeta` table. Learn more about how WordPress stores media library entries in the database here. You can delete them all in bulk using these commands: | |
DELETE FROM `wp_posts` WHERE `post_type` = "attachment"; | |
DELETE FROM `wp_postmeta` WHERE `meta_key` = "_wp_attached_file"; | |
DELETE FROM `wp_postmeta` WHERE `meta_key` = "_wp_attachment_metadata"; | |
You can run those in PHPMyAdmin or by logging into MySQL through SSH. I won't cover how to log in to either of those platforms here. If you're unsure, ask your hosting provider. | |
Files | |
Now that the database entries are gone, use FTP or SSH to delete the files themselves. They reside in your uploads folder: | |
/wp-content/uploads | |
Please note that many plugins add their own folders to the uploads folder. You probably don't want to delete those. By default WordPress stores your uploaded media library files in /year/month/ folders. |
I am working on a website generated with WP Staging plugin. Problem is... I cant find those tables. I dont want to use this query if it will delete the original website's tables too.
I am working on a website generated with WP Staging plugin. Problem is... I cant find those tables. I dont want to use this query if it will delete the original website's tables too.
If you want to delete only Media files that are uploaded over WP Admin, this is the code that you need. It will delete every Media that is uploaded there.
I am working on a website generated with WP Staging plugin. Problem is... I cant find those tables. I dont want to use this query if it will delete the original website's tables too.
If you want to delete only Media files that are uploaded over WP Admin, this is the code that you need. It will delete every Media that is uploaded there.
OK thanks :)
Thank you!
This was the thing that i needed. Thank you sir for this script !