Limit the Number of Post Revisions that WordPress Stores

WordPress saves post revisions for each edit made to a post or page. An edit is a saved or published post or page.You might not like this because revisions take up space in the database, which is where post revisions are stored. So imagine that you have 100 posts and pages in your database. For each post and page there are 10 revisions. That equates to 1,000 database records – not 100, a 1,000. The amount of database storage used will be intensified for mature blogs. Can you imagine? This can also have a negative impact on the speed of your website.

There is something you can do however. You can totally disallow post revisions storage or you can limit the number of post revisions using the WPPOSTREVISIONS constant.

The Options

There are three options for the WPPOSTREVISIONS constant, however only two are relevant for limiting the number of post revisions.

Add the option you want to your wp-config.php file.

Do Not Store Any Revisions

define( 'WP_POST_REVISIONS', false );

A Certain Amount of Revisions

define( 'WP_POST_REVISIONS', 5 );

In this example, I have limited the number of post revisions to 5. You can change it to more or less. You should also note that the number you set will be +1 for the autosave. There is only one (1) autosave per post or page.