Having revisions on my posts is nice I suppose. But I was starting to get a bit annoyed with the increasingly long list of revisions in each post. And they really did get long. Mainly because I am in a bit of a testing and experimenting phase which means that I have done a lost of adjustments to almost every single post so far because I don’t have 100% control on how I want things or how things will end up looking and so on
Anyways, I found a nice little MySQL snippet to clear out all of them in a French comment to a blog post. Thought I could share it here. Especially since I then know where to find it and it won’t disappear on me.
FROM wp_63nbis_posts x
LEFT JOIN wp_63nbis_term_relationships y ON (x.id = y.object_id)
LEFT JOIN wp_63nbis_postmeta z ON (x.id = z.post_id)
WHERE x.post_type = 'revision'
I did a select first (just swap delete x,y,z with select *) to check that it would delete what it was actually supposed to. And then a delete inside a transaction with another select afterwards, just in case
(All of which are very easy to do in MySQL Query Browser)
By the way, in the comments to that mentioned blog post there are also mentioned some other solutions to this problem. For example:
- Adding
define('WP_POST_REVISIONS', N);to your wp-config.php file, where N would be the maximum number of revisions you want to allow, or -1 if you want them all. - Add a plugin to WordPress called revision delete!.
















