Posted By

rickygri on 04/04/13


Tagged

sql delete wordpress media bulk


Versions (?)

SQL query to delete all media and attachments in wordpress


 / Published in: SQL
 

URL: http://wordpress.org/support/topic/delete-100000-images-from-media-library

Run these queries (phpMyAdmin will do) to delete all media in the library, and remove all post attachment affiliation

  1. # First:
  2.  
  3. DELETE FROM wp_postmeta
  4. WHERE post_id IN
  5. (
  6. SELECT id
  7. FROM wp_posts
  8. WHERE post_type = 'attachment'
  9. )
  10. ;
  11.  
  12. # Second:
  13.  
  14. DELETE FROM wp_posts WHERE post_type = 'attachment'

Report this snippet  

You need to login to post a comment.