The Fastest Way to Delete All Images in the WordPress Media Library

Want create site? Find Free WordPress Themes and plugins.

It takes hours to batch delete images if you have millions of images in your WordPress Media Library.

The following MySQL commands allow you to accomplish this in a few seconds.  Please make a backup of the MySQL database before you execute the command.

First, execute the following MySQL command.  It deletes the relationship between the media library attachments and the posts.

DELETE FROM wp_postmeta
WHERE post_id IN
(
    SELECT id
    FROM wp_posts
    WHERE post_type = 'attachment';
)

Next, run the following MySQL command to delete the attachments

DELETE FROM wp_posts WHERE post_type = 'attachment'
Did you find apk for android? You can find new Free Android Games and apps.

Leave a Reply

Be the First to Comment!

Notify of
avatar

wpDiscuz