How to limit WordPress post revisions with a simple line of code

You started a new WordPress site and you noticed that everything you save in a post also creates a revision. You make more changes and these WordPress revisions keep piling up. After a year of writing daily in your blog, you notice that your site’s database starts growing, but if you look closely almost 50%, if not more, is just because WordPress saves a copy of every change you make to a post.

WordPress by default doesn’t include an option to limit the number of post revisions, because it always wants you to be able to go back and rescue previous content. However, the content management system software does have a way to control the amount of revisions are kept for each post.

If want to limit the amount of copies WordPress saves for each post you write, do the following:

1. FTP your site, from the root directory find and download the wp-config.php.

2. Make a backup of the file!

3. Open the wp-config.php file with your favorite code editor and look for the WP_DEBUG line of code. Under this line copy and paste the following line of code:

/** Sets limit on WordPress revisions */

define('WP_POST_REVISIONS', 4);

Then number “4” is the amount of revisions I want to save, if you want to keep more or less copies, simple change the number. And if you don’t want to keep any copies simple enter the word false.

/** Disabling WordPress revisions */

define('WP_POST_REVISIONS', false);

4. Save the wp-config.php file and upload the file to your site. Go to your website refresh and test the new changes.