How can we disable and remove old post revisions from wordpress based website?

Old revision posts take too much space to wordpress based database.

In this article we will see how to remove old revision posts

Let’s see enable/disable post revision.

For disable post revisions add following code at top to wp-config.php file which is located to root directory of wordpress based websites.

define (‘WP_POST_REVISIONS’,false);

Above line will be disabled post revisions to database in the future. In case you would like to enable this post revisions sometime in future for any reason then just simply replace above line with

define (‘WP_POST_REVISIONS’,true);

Apply limit for generate post revisions

You can apply limit to generate post revisions which saved to database. Just have to add following line to you wp-config.php file.

define( ‘WP_POST_REVISIONS’, 3 );

This line will save up to 3 most recent revisions installed all of them. In other word older post revisions will be removed automatically once newer revisions are being saved. Also you can change the number 3 as per you want to keep number of most recent revisions.

Auto save setting interval for post revisions

Instead of default auto-save interval post revisions to database you can change it by add following code line wp-config.php file

define( ‘AUTOSAVE_INTERVAL’, 600 );

In wordpress  auto save post revisions interval time is every minute (60 seconds ) by default but by adding above line it will save post revisions time to every ten minutes (600 seconds). So it will reduce auto save post revisions automatically.

You can also use market plugin instead of add code line to wp-config.php file. Some good and plugins are WP-Sweep  and WP Revisions Control.

Now let’s see how to remove past revision post which are already created or stored to database?

Using Mysql query  you can remove all  past post revisions from your site’s database. For this open your site PHPMyAdmin and execute the following SQL query:

DELETE from wp_posts WHERE post_type = “revision”;

Above SQL query removes all posts from your database that have post_type = “revision”.

For securities reason, it’s always best to make backups of your database & files before you make drastic changes to it.

Leave a Reply

Your email address will not be published. Required fields are marked *