WordPress

How to Limit & Delete WordPress Post Revisions

How to Limit & Delete WordPress Post Revisions

In this article we’re going to walk you through two ways to delete your site’s stored revisions. The first way we’ll walk you through is a manual process directly inside of phpMyAdmin with a SQL query. If I just lost you, don’t worry! There’s also a very handy plugin you can use to achieve the same result.

  1. Using a SQL Query in phpMyAdmin
  2. Deleting WordPress Revisions in phpMyAdmin
  3. Delete Post Revisions with WP Optimize (plugin)
  4. Limit the Number of WordPres Revisions

WordPress is one of the most popular Open-Source Content Management Systems (CMS) in the world. The communities, support, and involvement from individuals to large enterprise has helped catapult WordPress to the top. Roughly 50% of our customer base has a website running off of WordPress and the popularity of WordPress continues to grow every year.

It’s a great solution for beginners and veterans alike. Though, many people using WordPress take for granted what’s under the hood. Just like a car needs an oil change, WordPress should be well maintained and checked periodically. If you’re using a CMS such as WordPress you’ll also have a database and tables where information is stored. The information stored here can vary from content on your site, information about your site, registered users, products, and more.

For anyone using WordPress you’ve probably noticed the Revisions section when you’re editing a page or post.

WordPress Post Revisions
By default, WordPress keeps an unlimited number of Revisions (changes) that are made to a particular page or post for you to refer back to. This functionality comes in handy if you make a mistake and want to undo that mistake by restoring your page or post back to a previous version.

Overtime, the number of Revisions will continue to grow. As the number of Revisions stored in your database increase, so does the overall size of your site’s database. For a small blogger, this may not have an impact on your site’s speed. Keep in mind that database size can directly impact your site’s speed and performance. Deleting WordPress post revisions can help get rid of old information that isn’t needed and significantly reduce the size of your database.

WARNING: Before proceeding with this tutorial, we highly suggest and recommend that you create a backup of your database and save it locally onto your computer. It’s always a best practice to back anything up, especially your database, if you’re going to make any changes.

1. Using a SQL Query in phpMyAdmin

Follow the steps below and use the following SQL query to delete revisions in phpMyAdmin.

DELETE FROM wp_posts WHERE post_type = "revision";

2. Deleting WordPress Revisions in phpMyAdmin

To delete post revisions in phpMyAdmin you’ll need to have access to your control panel. Once you’re logged into cPanel you’ll want to find the phpMyAdmin icon under the Databases section and click that icon:

Delete Post Revisions
Once you’ve clicked phpMyAdmin a new screen will load and take you inside of phpMyAdmin. For someone that’s never phpMyAdmin before it may be a little daunting. Don’t worry, we’ll walk you through each step of the process.

You’ll want to expand the database by clicking the ‘+‘ sign. Once you’ve expanded the database you will see many rows appear most likely starting with prefix wp_. These are your database tables. WordPress page and post revisions are stored in the wp_posts table.

Delete Post Revisions
To delete the revisions stored in the wp_posts database table you’ll want to run a SQL query. You don’t have to have the wp_posts database table selected. You can click on the database name and then the SQL tab at the top.

Delete Post Revisions
After the SQL tab has loaded you’ll want to paste the SQL query from above into the box and click the Go button (far bottom right of your screen).

NOTE: If your database tables have a different prefix (not wp_) you’ll want to be sure to change the ‘wp‘ in the SQL query on wp_posts to match your table’s prefix.

Delete Post Revisions

After you hit the Go button, the SQL query will run and delete any page and post revisions stored in your database.

3. Delete WordPress Revisions with WP Optimize

For those of you who don’t feel comfortable running a SQL query in phpMyAdmin there’s an alternative method you can use. The WP-Optimize WordPress Plugin by David Anderson will help you accomplish the same result by deleting your site’s page and post revisions for you directly through your WordPress dashboard.

You’ll want to search for, install the WP-Optimize, and activate the plugin. After you have activated the plugin you’ll see a WP-Optimize link in your WordPress dashboard’s left side navigation bar (near the bottom). Once the WP-Optimize page loads you’ll see different Run optimization actions. Search for the Clean all post revisions row and click the Run optimization button.

Delete Post Revisions
Now that you’ve clicked Run optimization, WP-Optimize will take care of the rest. You may not see the Notes column update after you click the Run optimization button. You’ll need to reload the page completely and you’ll see that your post revisions have been cleared. A new message No post revisions found under the Notes column will appear for that row.

4. Limit the Number of WordPres Revisions

Disabling your post revisions completely or continuously deleting those revisions may be task you don’t want to repeat over and over.

Alternatively, you can add a line of code to your WordPress site’s wp-config.php, which will limit the number of post revisions your WordPress site keeps. Add the following code to the wp-config.php and adjust the number ‘5‘ to the amount of post revisions you’d like for your site to store:

/** Set number of post revisions to keep */
define('WP_POST_REVISIONS', 5);

Limit WordPress Post Revisions
Now that this line of code has been placed in your wp-config.php your site will not store any more than five page or post revisions.

If you have any questions don’t hesitate to reach out to support or leave a comment down below!

Looking for reliable WordPress hosting with Award Winning Customer Support?
Grab your hosting today with a 20% discount. All plans come with our 60 Money Back Guarantee!

Previous ArticleNext Article