SQL to Delete WordPress Revisions

Contact us

SQL to Delete WordPress Revisions

While building and testing your WordPress website, you're likely to build up a history of unwanted post revisions, clogging up your WordPress database. The SQL command below will remove those old revisions and associated post meta data.

This SQL statement can be very useful if you use Advanced Custom Fields. Remember to do a database backup first.

DELETE a,b,c FROM wp_posts a LEFT JOIN wp_term_relationships b ON (a.ID = b.object_id) LEFT JOIN wp_postmeta c ON (a.ID = c.post_id) WHERE a.post_type = 'revision'

31 January 2018