What Are WordPress Post Revisions and How to Use Them

Even if you’ve used WordPress for years, you may still be surprised by some of its features’ usefulness.

For example, many people ignore post revisions until they need to undo an unnecessary edit or restore lost content.

But how can you really make the most of post revisions? And are there cases when they might not be quite so helpful?

Let’s find out.

What Are Post Revisions in WordPress?

You may or may not have noticed that WordPress has an autosave function. While you’re editing, the content management system saves a copy of the post with your latest changes once every sixty seconds. If you experience a power outage or a browser crash, you can later continue editing the post without losing any work.

This is how the autosave function works from your perspective. But what happens behind the scenes?

Every sixty seconds, WordPress takes a snapshot of the post you’re editing and stores it in the database. This snapshot is known as a post revision, and you can later restore it, so you don’t lose your edits. In the case of autosaves, every revision stays in the database for one minute before being overwritten by the next one.

Something similar happens when you save your work yourself. Every time you press the Save Draft, Publish, or Update buttons, WordPress takes the post in its current state and writes it to the database as a revision.

These revisions are not overwritten. You can update the post several times and undo the changes by restoring an older post revision. In many ways, a revision is a backup. You can tweak the content infinitely without worrying about losing any data.

But when will you actually need to browse through and restore post revisions?

When Should You Use Post Revisions?

Creating quality content can involve a lot of editing sometimes. Thanks to revisions, you can go back, see the changes you’ve made to a post, and figure out whether they’ve done a lot to improve the content. If they haven’t, you can easily undo them.

Revisions let you see how the content evolves and allow you to change the direction if you’re not happy with the results. You get more freedom in experimenting with different techniques without worrying that if they don’t work out, you’ll need to spend ages trying to get back to where you started.

Revisions can be useful for tracking changes as well. If you have multiple users working on the same post, you can see who has done what and when they’ve done it.

Let’s see how revisions work in action.

Undoing Changes With Post Revisions

You can browse and restore post revisions straight from the editor. The link is available from the menu on the right and leads you to the interface showing you the actual changes.

The screen is divided into two. On the right, you see the post in its current state, and on the left is what it looked like before the last revision. WordPress uses green and red highlighting to show you elements added and removed during the revision.

Above the post itself, there’s a slider you can use to browse all available revisions. If you hover the mouse cursor over individual revisions, you’ll see the date and time of the edits and the author who carried them out.

On the right, you have a Compare any two revisions option. It enables a second slider that lets you see the post in any of its variants and compare the content across revisions.

Below the slider, you can see the revisions you’re comparing, and with the Restore This Revision button, you can restore the post to the state displayed on the right-hand side of the screen.

This, in turn, will generate another revision that will also be available in the same interface.

Limiting Post Revisions in WordPress

A lot has been said about post revisions and their effect on website performance. Some people argue that post revisions bloat up the WordPress database and slow down your website. Others say that revisions are called only when you try to access them via the WP dashboard, so they don’t affect loading speeds in any way.

One thing is certain – the more revisions you have, the larger your database. The larger the database, the larger and slower the backups, and the more likely you are to run out of storage space. If this sounds like a problem you might encounter, you can avoid it by limiting the number of revisions per post.

This being WordPress, you can do it with a plugin. There’s certainly no shortage of options in WP’s official plugin repository. Some are dedicated specifically to this task, while others can take care of other performance optimization measures.

You can check what these plugins do and decide for yourself whether they can be helpful. However, if your only goal is to limit the number of revisions per post, you should at least consider doing it manually. There’s nothing too technical about the process, you won’t need hours to do it, and by skipping the plugin, you’ll keep clutter to a minimum.

All you need to do is add a single line to the wp-config.php file. The wp-config.php file is the primary configuration file in WordPress, so before you modify it, it might not be a bad idea to back it up just in case.

You’ll find the wp-config.php file in your site’s document root folder (if it’s hosted under the account’s primary domain, it should be in public_html). You can download it with an FTP client and edit it locally, and you can also access it via SSH. However, because most hosting accounts come with a browser-based file manager that can edit files on the server, this is the option people usually prefer.

Open wp-config.php, locate the line that says “/* That’s all, stop editing! Happy publishing. */“, and add the following code above it:

define( ‘WP_POST_REVISIONS’, 3 );

This limits the number of revisions per post to just three. You can put any number you want in there.

Don’t forget to save the changes before closing the file.

Completely Disabling Post Revisions

As a more drastic measure to keep the database size at bay, you can disable revisions altogether. Once again, you can do it with a WordPress plugin, or you can edit the wp-config.php file. 

If you opt for the second option, the line you’ll need to add is the following:

define(‘WP_POST_REVISIONS’, false );

Deleting Old Post Revisions

All your post revisions are kept in your WordPress database, so you probably have a means of accessing and deleting them either via the command line or through a graphic user interface. However, manually removing them one by one could take ages. Dropping them all with a single action would be much more convenient. Thankfully, you can do it with phpMyAdmin.

The phpMyAdmin database management system is integrated into most popular web hosting control panels. With it, you can delete all your WordPress post revisions with a simple SQL command.

First, open phpMyAdmin and select your WordPress database from the menu on the left. If you don’t know which database your site uses, you can find its name in the wp-config.php file.

Next, you need to click the SQL tab to open phpMyAdmin’s SQL interface. To delete all post revisions from the database, enter the following command:

DELETE FROM wp_posts WHERE post_type = “revision”;

NOTE: Check whether your site works with the default WordPress table prefix – wp_. If you’re using a custom prefix, you’ll need to change it in the line above.

The Simulate query button will do a dry run and show you how many database entries will be deleted if you proceed. If you’re sure you want to delete all your revisions, click Go.

If you’re comfortable working with the command line, you can access your account via SSH, log into the MySQL server, and execute the same query.

Conclusion

Post revisions can indeed weigh down your database, but they can also be extremely helpful, especially if you don’t like losing work and want to improve your content to a tee. Many people claim that disabling revisions is a crucial performance optimization step. However, instead of following the advice blindly, you’re probably better off considering revisions’ advantages and disadvantages and figuring out how to use them in the most efficient way possible.

FAQ

How do I add post revisions in WordPress?

Revisions are generated automatically every time you publish, update, or save a post as a draft. Additionally, while editing a post, WordPress autosaves your changes and lets you restore them in case of a power outage or a crash.

How do I restore a post revision in WordPress?

 After you open a post in the block editor, you’ll see the number of revisions in the menu on the right. It leads you to a timeline with all available revisions and information on who has created them as well as a visual representation of what has changed. After you choose your revision, restoring it is a matter of clicking a single button.

How do I delete post revisions in WordPress?

All your post revisions are stored in the wp_posts table (the wp_ prefix may be different on your site) inside your WordPress database. You can use the command line or a GUI-based database management tool to view and remove individual revisions. With a single SQL query, you can also delete all revisions at once.

Was this article helpful?

What’s your goal today?

1. Find the right WordPress hosting solution

If you’re looking for industry-leading speed, ease of use and reliability Try ScalaHosting with an unconditional money-back guarantee.

2. Make your website lightning-fast

We guarantee to make your WordPress site load in less than 2 seconds on a managed VPS with ScalaHosting or give your money back. Fill out the form, and we’ll be in touch.

Make your website lighting fast—or your money back
Slow websites lose visitors and sales. See how you can surf tsunami sized traffic spikes—or any traffic—with ease with ScalaHosting. Fill out the form, and we’ll be in touch!
Please enter a valid name
Please enter a valid website
This site is protected by reCAPTCHA and the Google Privacy Policy and Terms of Service apply.

3. Streamline your clients’ hosting experience

If you’re a web studio or development agency hosting more than 30 websites, schedule a call with Vlad, our co-founder and CTO, and see how we can deliver unmatched value to both your business and your clients.

Photo

Need a custom cluster or professional advice?

Book a meeting and get a free 30-minute consultation with Vlad, co-founder & CTO of Scala Hosting, who will help you select, design and build the right solution - from a single data center cluster to a multi-region & multi-datacenter high availability cluster with hundreds of servers.

Book a free consultation

4. Learn how to grow your website in 2024

An all-star team of SEO and web influencers are sharing their secret knowledge for the first time in years. Learn about the future of SEO, Web Design best practices and the secrets to getting the foundation for your website to thrive. Watch the exclusive webinar.

An Exclusive Insiders Look Behind The SEO and Web Development Curtain