How to limit and disable post revisions on WordPress to save space

A very handy WordPress feature, especially for bloggers, is post revisions. It allows you to look back over earlier versions of your blog post so you can undo changes, compare two versions and revert to an earlier version.

By default, WordPress stores an infinite number of revisions. So every time you edit your blog post and save as a draft or update a published post, WordPress stores a copy on your database. Combine this with auto-saves and the number of posts you have on your blog and you can see how this space can get pretty big. You could have 20+ versions of each blog post stored! This could be vital space if you’ve got a smaller hosting package.

This tutorial will show you how to limit the number of blog post revisions that WordPress stores per post on your database as well as how to delete old post revisions from published posts.

How to limit or disable post revisions on WordPress to save database space

How to limit the number of stored posts revisions

You can set restrictions so that only a set number of recent revisions are saved per post. To do that connect to your site via FTP and open the wp-config.php file in your roots directory. Find the line that says

/* That's all, stop editing! Happy blogging. */

and above that line add the following

/* limit post revisions xomisse */
define( 'WP_POST_REVISIONS', 3 );

Change the number to how many revisions you want stored, plus one auto-save. The older versions will be automatically deleted once newer versions are saved.

How to limit or disable post revisions on WordPress to save database space

How to Disable/Enable Post Revisions

This section will show you how to disable post revisions from being saved to your database in the future.

Open the wp-config.php file located in your roots directory and find the line that says

/* That's all, stop editing! Happy blogging. */

Above that line add the following

/* disable post revisions xomisse */
define( 'WP_POST_REVISIONS', false );

To enable post revisions again, simply replace it with

/* enable post revisions xomisse */
define( 'WP_POST_REVISIONS', true );

How to remove old post revisions

The easiest way to do this if you aren’t very “techy” is by using a plugin, such as Better Delete Revision, Revision Control, Optimize Database after Deleting Revisions or WP Optimize.

Leave a Reply

Thank you so much for taking the time to comment! Your email will not be published or shared but you will recieve an email if your comment has a reply. Need help with a tutorial? Check out our Coding + Consultation service for one-on-one assistance.