Skip to content

Instantly share code, notes, and snippets.

@milohuang
Created November 5, 2011 23:20
Show Gist options
  • Star 0 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save milohuang/1342178 to your computer and use it in GitHub Desktop.
Save milohuang/1342178 to your computer and use it in GitHub Desktop.
WordPress Delete Revisions 2
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'
-- If for some reason you associated a revision with
-- a tag or a category that was then removed when the
-- final post was published, you will have extra entries
-- in other tables such as terms.
-- http://weblogtoolscollection.com/archives/2010/09/28/deleting-wordpress-revisions/
@ashfame
Copy link

ashfame commented Nov 5, 2011

Even that will leave traces, best is to use WordPress functions to delete post. See http://blog.ashfame.com/2010/04/handling-wordpress-post-revisions-correctly/

@milohuang
Copy link
Author

Great man, that's really helpful :)

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment