Post revisions and Autosave off

[Original article source: JamesICT]

One of the latest features of WordPress is the inclusion of post revisions [since about version 2.6 if memory serves me correctly] and whilst I can see the use of it in some instances, personally, I would rather it was not automatically enabled.

Basically, it is an autosave function and I find that it gets in my way rather than helps me in my writing. There is always going to be that instance when I wish it was there I guess, but having not had it in place for so long, i just don’t need it now.

So, how to disable it? It would be nice if there was a tickbox which would allow for this, but unfortunately there isn’t. So it involves a simple piece of code being added to your wp-config.php file.

To do this, you need a text editor [no. not Notepad] and you simply add the following line of code to the file [directly under the other lines of ‘define’ already in place].

define(’WP_POST_REVISIONS’, false);

Alternatively, you can limit the amount of post revisions saved if you wish. use the following coe and change the number ‘4’ to whatever suits you best:

define(‘WP_POST_REVISIONS’,4);

There is also a simple little plugin that will do this for you at http://exper.3drecursions.com/2008/07/25/disable-revisions-and-autosave-plugin/

Deleting Post Revisions already made.

One other aspect to mention here too. It may be that you already have lost of post revisions and you now want to get rid of them all. This does involve using phpMyAdmin though [or other MySQL manager] and you need to run a bit of code via your SQL QUERY panel. [Original source: via]

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’

Just make sure that your WordPress installation is using the prefix: wp_

If not, adjust the code to suit your changed prefix.

[As always, if you need a hand to do any of this, please do get in touch with us.]

Leave a Reply