Delete and limit WordPress revisions

Sometimes when you open a WordPress post or page and begin to edit it in the Dashboard, you may find a large number of revisions saved from the Publish box at the upper right section.

When you open a WordPress post or page and begin to edit it in the Dashboard,

Also you will find a specific Revisions box below the post editing box. If you didn’t see this revision list, you can turn it on from Screen Options in WordPress dashboard.

wordpress post revisions list in dashboard

From the above screenshot, you can see a list of several post revisions and an autosave. In case of data loss, WordPress users can make use of the revisions to get back their unsaved content or roll back to an earlier version of the posts or pages. WordPress stores a record of each saved draft or published update in the revisions. The autosave can even take advantage of the local storage feature of user’s browser to automatically saves changes made to a post or page when the internet connection is lost unexpectedly.

By default, WordPress automatically save your content in every 60 seconds and this can be changed in the WordPress configuration file (wp-config.php). New autosaves overwrite old autosaves. Thus each WordPress user only have one autosave for any given post. WordPress revisions however can really add up quickly as each revision is stored without overwriting previous ones. If you don’t clear up the lots of revisions from your WordPress database, you will find much database space wasted in saving these out-dated unnecessary data.

In this post, we will discuss how to quickly delete WordPress revisions from the database and limit the number of revisions from WordPress configuration file.

Backup WordPress database before any change

You should backup your WordPress database before making any changes to it. There are different ways to create backups of MySQL databases. You can do that from cPanel, using a WordPress backup plugin or through the free MySQL management tool, phpMyAdmin. Check out this quick guide to backup WordPress database using phpMyAdmin.

Delete existing WordPress revisions from database

WordPress page and post revisions are stored in the wp_posts table. You can access them using a database tool such as phpMyAdmin which should be provided for free by most WordPress hosting services.

phpmyadmin mysql database management tool

In this demo, we will use Bluehost web hosting, one of the best known WordPress hosting service provider, to show you how to delete WordPress revisions.

Log on cPanel, scroll down to the Database tools section and click to open phpMyAdmin.

database tools phpmyadmin in cpanel

The system will redirect you in a few seconds, you will then find a list of all existing MySQL databases in phpMyAdmin.

edit mysql database in phpmyadmin

Click to expand the WordPress database, browse to wp_posts table, you can find, delete revisions along with regular posts, pages, attachment, etc. The easiest way to delete WordPress revisions would be using a SQL Query in phpMyAdmin. Once you opened a database in phpMyAdmin, click the SQL tab at the top tools bar. Copy and paste below SQL query into the box and click the Go button (far bottom right of your screen).

Delete from wp_posts where post_type = "revision";

delete all existing wordpress post revisions from database using phpmyadmin

You will get a warning messages in the pop-up window. Confirm to execute the query. It will then delete all existing page and post revisions stored in your WordPress database quickly.

Limit the number of WordPress revisions

Want to limit the number of posts revisions other than storing every post revision in the database? The limit can be set in wp-config.php file. Find and open the wp-config.php file in a code editor and add following code to limit WordPress revisions to a certain number, such as 3, 4, 5 revisions for all posts and pages.

define('WP_POST_REVISIONS', 3);

The above code will save only three WordPress revisions.

limit number of wordpress post revisions in wp-config.php

define('WP_POST_REVISIONS', 4);

The above code will save only four WordPress revisions.

If you like to disable WordPress post revisions completely, use this code in the wp-config.php file:

define('WP_POST_REVISIONS', false);

For cPanel hosting users, you can find and edit web pages and files from cPanel >> Files >> File Manager.

Leave a Reply