“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.
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.
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.
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:
- you can configure how many revisions to store,
- You can use caching and CDNs etc so your website is not slowed down, even if you have a very large database,
- 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.
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.