How to Limit, Disable or Delete Post Revisions in WordPress

Why Would You Want to Delete Post Revisions?

Every time you save a draft or update a post WordPress will save a copy of the old version. That way, if you need to revert back to the old version you can. Having Post Revisions in WordPress can be a lifesaver for some people and a nuisance for others.

For me personally, it’s just something that fills my database with thousands of unneeded pages. This can slow down WordPress considerably. It’s not necessary in my opinion to have thousands of pages stored, maybe two or three at the most. Below I will give several examples of how you can solve this problem.

How to Limit Post Revisions

If you don’t want to completely get rid of Post Revisions and just limit the number that is saved to your database, add the code below to your wp-config.php file in your WordPress root directory:

Place this code at the top of your wp-config.php file, otherwise it will not work.

define('WP_POST_REVISIONS', 3);

You can change the number 3 to anything you want based on how many revisions you would like to save per post/page.

How to Disable Post Revisions

To completely disable Post Revisions, add the code below to your wp-config.php file in your WordPress root directory:

Place this code at the top of your wp-config.php file, otherwise it will not work.

define('WP_POST_REVISIONS', false );

If you ever need to revert back, you can simply replace the value “false” with “true” and everything will be back to normal.

How to Delete Post Revisions

To get rid of all revisions that are stored in your database you will need to run an SQL query in phpMyadmin. Login to your cPanel and click the phpMyadmin Icon. On the left hand side select the database you want to clean up.

Click the tab labeled “SQL” and paste the following code inside:

Warning: Before you run this SQL query make sure you don’t need any of your revisions as they will be gone forever.

DELETE FROM wp_posts WHERE post_type = "revision";

Run this query by clicking the “Go” Button and all post revisions will be removed from your database permanently.

Change the Autosave Interval

One other thing you can change is the autosave interval. By default, WordPress will save the post you are working on every 60 seconds. Some people might find this to be a bit to often. If you would like to change this value, add the following code to your wp-config.php file:

Place this code at the top of your wp-config.php file, otherwise it will not work.

define('AUTOSAVE_INTERVAL', 120 ); // seconds

The value 120 would be 2 minutes. You can change this value to whatever you want depending on if you want WordPress to autosave more or less often.

If you enjoyed this tutorial, please be sure to follow us on Facebook and Twitter. You can also find us on Freelancer if you need some help with your WordPress website or web development issues.

More Great Tutorials

David Green

My name is David and I am the founder and author of Zuziko. I am passionate about web development and have created Zuziko as a way to share my knowledge and experience with the world.

2 thoughts on “How to Limit, Disable or Delete Post Revisions in WordPress”

  1. Asad Hanif

    Hi David,

    If I put the following code:

    define(‘WP_POST_REVISIONS’, false);

    It’ll stop any further revisions, even page revisions?

    Thank you!

    • David Green

      Hi Asad,

      That is correct, the code shown above will also stop page revisions.

Leave a Comment

Share via
Copy link
Powered by Social Snap