Have you notice that WordPress saves post revisions for you?  It is a great feature.  Try it out yourself.  Edit a post, click “Update”, and voila, you have Post Revisions.

But sometimes, post revisions can seem to get out of hand.  Do you really need or want hundreds of revision histories?

Well, WordPress is here to help you.

First, let me mention that revisions take up space — usually a lot of space.  Each revision is held as a separate entity within the database.  Therefore, unlimited revisions is usually not a great idea.  But having revisions is usually a very good idea, as you may already know.

Steps involved

There are a few settings available to modify how WordPress will be handling revisions for you.  They are all contained in the wp-config.php hosted in the main directory of your WordPress instance.

1. Defining the number of revisions

Revision count is set in the line

define( 'WP_POST_REVISIONS', REVISIONS );

Where REVISIONS is

  • true or -1: This is the default option in WordPress.  WordPress will store every revision of every post
  • false or 0:  This eliminates all revisions.  The only version retained is the most recent saved version.
  • Any number greater than 0:  This limits the number of revisions to a specific number and automatically deletes all other revisions.

2. Defining the Autosave interval

WordPress will automatically save posts for you after a defined number of seconds.

define( 'AUTOSAVE_INTERVAL', SECONDS ); // Seconds

Where SECONDS is interval at which an autosave will occur.

A word of warning

Optimally, you may think that setting AutoSave to a very low number of seconds is the best!  This would mean that even if the power goes out or the Internet becomes unavailable, you haven’t lost any work.  And this is true!

But consider this also. Each version that is AutoSaved potentially takes a lot of space.  This might not be optimal.

So then you might consider, okay, just make the REVISIONS a reasonably low count, and your site will be fine again!  Well, maybe.  Consider it this way.  If REVISIONS is set to say 15 (which sounds like a reasonably high number), and AutoSave is set to 60 (seconds), then regardless of whether you have explicitly saved a copy of the page, the revision history disappears after fifteen minutes.

That might not be optimal for you.

I don’t have a magic answer for you here, other than to say, be aware.  For me, I’ve set my AUTOSAVE to 120 seconds (I normally save more often than this), and I’ve set my REVISIONS to 50.  In my case, I’m running my own server farm, and I have potentially unlimited database space, so retaining many revisions is not a big deal.  Your situation may be different.

Recap

Edit wp-config.php located in the main WordPress directory with the following two lines:

/********************
Post Revisions
* WP_POST_REVISIONS is the number of Revisions to keep.
Revisions = "true" or -1 for Unlimited history (default)
Revisions = "false" or 0 for no storage of revisions (not advised!)
Revisions = some positive value for limited history, ex "10" or "50"
* AUTOSAVE_INTERVAL is the number of seconds between revision autosaves
Autosave is set to 60 by devault
********************* */

define( 'WP_POST_REVISIONS', -1 ); // counts unlimited
define( 'AUTOSAVE_INTERVAL', 120 ); // Seconds

Now that you are actively saving your editing content, make sure to check out how to select WordPress Plugins and how to protect WordPress wp-login.

If you have any questions or comments on this article please leave me a note by clicking here.

Leave a comment