Limit Post Revisions in WordPress without a Plugin

WordPress Post Revisions allows the saving of WordPress post backups and revisions in the database.

Revisions can be compared as well as restored using this feature.

To limit the number of post revisions in WordPress follow these steps:

Log into your WordPress web host using FTP or any other preferred method.

Navigate to the root of your WordPress directory. Find the exact file called wp-config.php. Open this file to edit. Be very careful while editing this file.

Add the following line to your wp-config.php file (If you do not have the line already). You need to add this line after define(‘DB_COLLATE’, ”);
define( 'WP_POST_REVISIONS', 3 );
The 3 in the above line specifies how many revisions you want for your single post. You can change it to any integer value like 4 , 5, 6, …

Save the file and close it. Now your posts will only have limited revisions i.e. 3 in this case.

To disable WordPress post revisions:

Follow the steps above and open wp-config.php.

If you do not have the line, add the following line to the wp-config.php file:
define( 'WP_POST_REVISIONS', false );
The false above specifies that post revisions is no longer wanted in WordPress. It is disabled completely. You can change the value to true to explicitly state that you want maximum post revisions in WordPress i.e. 25 now.

About Limiting Posts Feature in WordPress

WordPress is a great blogging tool and it has added some great new features every now and then. New version of WordPress generally come with bug fixes, security fixes and to everyone’s’ anticipation, new features. One of the features of WordPress that is relatively new is “Post Revisions”. I don’t remember the last time I saw this feature in WordPress, but now I’ve started noticing it and I feel quite safe that I will now not lose any modifications to my posts.

Post Revisions save backup copies of your post while you are actually writing a new post. When you are composing a new post, you tend to save draft. When you do so a copy of your post up to that point is also saved as a revision post. Even after you’ve published a post, you tend to update it when you find mistakes or when you need to make some changes. When you do so, your backup copy of your post is saved as a post revision.

Using post revisions, you can compare different versions of your post. Line by line or better yet, word by word comparisons can be made. WordPress can display two version of a post side by side. This way you will no what changes you have made. You will be able to recover any lost data if you happen to lose any while updating your posts. With post revisions it is also easy to revert a post to an earlier version.

We all know that, a highly optimized database is the solution to speed up our WordPress blog or website. A solution to large increased number of post revisions, however, exists easily. This is WordPress and there is a solution for almost anything in WordPress. The best solution to large number of post revisions is to limit the number of post revisions per blog post. You can, let’s say, limit the number of post revisions to 3 per single post. This way your database size will be much less and your site will potentially be quicker.Although, this is a great feature in WordPress, we have to understand that high number of revisions for a single post means an even higher number of post backups for all our posts. Let us just put it this way. We have 100 posts in a blog and there are 5 average post revisions for each blog posts. That means at least 500 entries in the database, thanks to the revisions. While this might not be a problem for many web hosts and database hosts, users can still face some database optimization issues. A lot of entries in the database can mean the size of the database is huge and it takes longer time to query it.