WordPress tip: Get rid of unused post revisions

WordPress tip: Get rid of unused post revisions

Just run the following query on your WordPress database, and all revisions (As well as meta associated with it) will be deleted from your database.
Of course, do not forget to make a backup of your database before running the code.

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

If you’d like to see more SQL queries for WordPress, make sure to read this post.

Thanks to One Extra Pixel for this cool query!

Looking for WordPress hosting? Try WP Web Host. Prices starts at $5/month and you can try it for free!

WordPress tip: Get rid of unused post revisions

Leave a Reply

Your email address will not be published.