7/7/2016 - 4:51 PM

WP revisions

WP revisions

//* While revisions are useful and I wouldn’t personally disable them, nor would I recommend disabling them, you can save space in your database by removing old revisions. To keep a maximum number of revisions, you can add a handy define to your wp-config.php file:

define( 'WP_POST_REVISIONS', 5 );

//* Just change the number to however many revisions you want to keep. Entering 1 or more stores the number of revisions plus the autosave, -1 stores every revision, and 0 sets it to false and stores no revisions except the autosave.
WordPress 2.6 introduced a post revision feature, which allows you to store previous versions of a post, i.e. saves all drafts and updates. Contrary to popular belief, only one autosave is kept per post, automatically removing the old autosaved version. This means that your table won’t keep growing with autosaves. However, your table will increase every time you click “Update” on your post or save a new draft.

//* To remove revisions from existing posts, you’ll need to either run an SQL command to remove them or use a WordPress optimization plugin to remove them. If you wish to use SQL, you can run a command like this:

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'