Set limit to number of page post revisions store in database – WordPress

WordPress is one of the most using web software that use by million of people to create a beautiful website, blog, or app. it comes with many features which make it popular and widely use from last decade.

Benefits of Revisions Feature One of the wordpress feature is it save all page post edit revision version into your site Database. When ever you edit page / post and press Update button than before edited version save into database as Revision and if you want to restore something that was looking good than now, you can easily restore it without re-doing same setting or content setup.

Revision version increase Database size : As With wordpress most of theme comes with page builder we all doing like edit and see hows it look. like this way number of revision store into database and size of Database increase which affect your website overall performance. to control our Database size we have to clean unnecessary revision version that we can do by using WP-Optimize wordpress plugin.

One other permanent solution for control Page post revision is set limit how many number of Page post Revisions keep into database by use of wordpress filter wp_revisions_to_keep and no need any plugins.

If you want to set limit to number of page post revisions being store in the wp website database then simply add following code into your active theme or active theme child theme’s functions.php:

add_filter( 'wp_revisions_to_keep', 'ls_limit_revisions', 10, 2 );
function ls_limit_revisions( $num ) { 
 $num = 5;
 return $num;
Scroll to Top