Home Blog WordPress Management Managing WordPress Revisions for Posts and Pages

Managing WordPress Revisions for Posts and Pages

Managing WordPress Revisions for Posts and Pages

“The WordPress revisions system stores a record of each saved draft or published update. The revision system allows you to see what changes were made in each revision by dragging a slider (or using the Next/Previous buttons). The display indicates what has changed in each revision – what was added, what remained unchanged, and what was removed. Lines added or removed are highlighted, and individual character changes get additional highlighting.”
 WordPress Codex (the online manual for WordPress)

The WordPress revisions system also allows you to undo content changes and restore older versions of posts and pages. The WordPress revisions system works for posts and pages. There are third party solutions that can enable revisions for posts with custom types though we won’t be covering them in this post.

Do You Need Revisions on Your WordPress Website?

If you write a lot of content, or have a team of people working on the website it can be a life saver. Revisions are certainly a must have for business websites. In some cases, businesses operating in the finance, legal, healthcare and similar industries are legally obliged to keep a record of all the changes that happen on their WordPress website, including content changes. There are also many regulatory compliance rules that specifically require businesses to keep a record of every change that happens on their WordPress website.

The WP Activity Log plugin uses the WordPress Revisions to keep a record of all content changes on a website it is installed on.

How Do WordPress Revisions Work?

WordPress revisions are enabled by default but in some cases they might be turned off by the hosting provider. To check if they are enabled on your WordPress website make a small content change to a post or page and save it. If revisions are enabled the Revisions count should be updated in the top right hand side pst status box, which is highlighted in the below screenshot.

WordPress Revisions counter

Reviewing Posts & Pages Revisions

Once you make changes to a post or page, and a revision is saved then you can use the Revisions viewer to see the changes. The red and green markers highlight which of the text was removed, updated and changed in between posts. The slider at the top can be used to browse through the different revisions of that post.

Reviewing the different revisions of a WordPress post or page

You can also compare two different revisions of a post in the revision viewer by clicking the option Compare any two revisions and using the slider to select the revisions, as seen in the below screenshot.

Comparing two revisions of a post

Revisions and the WordPress Database

Every time you update the title, content or excerpt of a post or page WordPress adds an additional entry in the WordPress database. The new entry is a new row in the wp_post table, as if a new post was created. The main differences between a row in the database of a new post and that of revision are the values of the post_name and post_type columns.

POST_NAME COLUMN & VALUE

The value of the post_name column is the title of the post. Though when a revision of a post is saved, the following naming format is used – [post ID of original post]_revision_v1. Therefore if the revision of post ID 43 is saved, the value of the post_name value would be 43_revision_v1.

POST_TYPE COLUMN & VALUE

The value of the post_type column is the type of post, such as post, page or a custom post type. In case of a revision, the column is set to revision.

Do Revisions Make the WordPress Database Bigger?

Yes, by adding additional entries to the database the WordPress database will be bigger. Though you can configure how many revisions to store as explained further down in this post if the database size is an issue.

Do Revisions Slow Down the WordPress Database?

It depends on how many posts and revisions you have saved, though the bigger the website gets the more the database is hampered. Though this is normal and should not be of a worry because:

  1. you can configure how many revisions to store,
  2. You can use caching and CDNs etc so your website is not slowed down, even if you have a very large database,
  3. You can use a better spec’d web server.

TIP: Revisions are very useful to writers and authors, and also for compliance reasons, so do not disable them unless you really need to. Though once a piece is published, unless you are legally bound to keep revisions you can delete its revisions since at that stage revisions are of no use.

Configuring Revisions

Below are a list of filters you can use in your wp-config.php file to enable, disable and configure revisions.

Enable or Disable Revisions


define( 'WP_POST_REVISIONS', true );

You can use any of the below two options for WP_POST_REVISIONS filter, which are;

  • True: This is the default. WordPress revisions are enabled and every revision is stored.
  • False: This disabled the WordPress revisions entirely. Note that recent autosaves still work.

Configure Revisions Limit

You can also use the same WP_POST_REVISIONS filter to configure the number of revisions to keep. So for example if you specify the below in the wp-config.php file only three revisions per post are saved:


define( 'WP_POST_REVISIONS', 3 );

You can specify any positive integer to configure the number of revisions WordPress should keep for every post or page. Older revisions will be automatically deleted as newer versions are stored.

Using Plugins to Purge Revisions

There are a few WordPress database optimization plugins you can use to clear out the revisions. One of our favorite one is WP-Optimize. We also like WP Migrate DB Pro because it is an all rounder database admin plugin, which includes both optimization and admin tools. They also have a free version available on the WordPress repository.

Taking Advantage of Posts & Pages Revisions in WordPress

To recap, WordPress revisions is one of the most useful tools in WordPress. If you are an author, auditor or administrator you will surely need it from time to time, so make sure it is enabled. If you are worried about the database size or performance, limit the number of revisions you keep in the database and install a caching solution, although you should not be unless you have thousands of posts and revisions.


6 thoughts on “Managing WordPress Revisions for Posts and Pages

    1. Hello Bob, yes it is possible. The plugin uses event ID 2065 to keep track of content changes (complete list of event IDs). So you create a report by setting up a criteria for events with ID 2065 and the start and end date that you want, and you’ll have the report.

      Hope this helps. Do not hesitate to reach out should you have any further queries.

  1. Great post BTW! Lots of great info. I used the WP_POST_REVISION in my wp-config file.

    Wondering if there is a way to delete all except the last 2 revisions? It seems all the plugins delete everything and although I have it set to only save the last 3 revisions, it doesn’t appear to remove the rest.

    1. Hi Tess,

      I’m glad that you found this article helpful.

      Yes, you can configure the number of revisions you want to keep by using this line: define( ‘WP_POST_REVISIONS’, 3 );

      You can specify any positive integer to configure the number of revisions WordPress should keep for every post or page.

      Regarding your other question, could you please clarify what do you mean by that all the plugins delete everything, and it doesn’t remove the rest?

      Best wishes,
      Rado

    1. Hello Jon,

      Hope you are doing well, and thanks for reaching out!

      The activity logs are something that the plugin creates, however when it comes to content changes, the WP Activity Log plugin uses the WordPress revisioning system meaning that if you install it on your website it will provide you with all content related logs that are already in the database.

      Let us know if you have any other questions or concerns.

      Best wishes,
      Rado


Leave a Reply

Your email address will not be published. Required fields are marked *

Stay in the loop

Subscribe to the Melapress newsletter and receive curated WordPress management and security tips and content.

Newsletter icon

It’s free and you can unsubscribe whenever you want. Check our blog for a taste.

Envelope icon
newsletter-pop-up