Limit Number of Post or Page Revisions

Limiting the number of post or page revisions can help the responsiveness of a WordPress website. A small change to a WordPress configuration file can improve your website.

Editing a WordPress post I tend to save frequently: enabling me to see the changes within the context of the website and just to be sure, in case something should happen and I lose the edits which I have made.

With each save my list of revisions grows. Realistically its only the latter ones which I am interested in. Its doubtful that one of the older entries will have the missing paragraph of text.

If I can reduce the long list of revisions on the page then so much the better. Its distracting and makes the page longer, with a large block to scroll past.

I am also aware that all of these revisions is making for a larger database. The impact will be two fold:

  1. A larger memory footprint will make it less likely that the database will sit wholly in memory, making processing slower.
  2. More entries in the database will affect the speed that the database server returns a particular post entry.

The limiting of the number of revisions are turned off by default.

There are plugins available which allow the revisions to be managed, either by offering a table of entries for deletion or by restricting the quantity per post by date or quantity.

A simple edit of the wp-config.php file, in the root of the website, will allow the number of revisions to be retained, per post, to be set.

The entry to be added to the wp-config.php file is

define( ‘WP_POST_REVISIONS’, 10 );

To be effective the entry must be located before the entry

require_once(ABSPATH . ‘wp-settings.php’);

The change to the file may be made either through the host control panel for the website or via FTP.

I made the change to the file, edited a post in development and the number of revisions available was now reduced to 5:

Revisions: 5+ Browse

Changes to the revisions retained are updated when an entry is edited.Old posts will retain their existing quantity of revisions.