Learn about the Autosave feature in WordPress, and how to modify it on your site

Have you ever been writing an article, or designing an important page on a website that uses a content management system (CMS) that does not provide automatic saving, and the browser window closed by mistake, or your connection to the Internet was cut off, or your computer turned off due to a loss of electrical power…and after that If you return to the article or page later, you find that the work you did did not save your time in vain!

Here comes the importance of the Autosave feature provided by the WordPress system, as it is considered one of the important features that gives you peace of mind while editing your posts, and enables you to retrieve any content that you were unable to save for any reason.

In this article, we’ll explain in detail how autosave works in WordPress, why it’s important, and explain the difference between it and revision history. How can you control it on your site in different ways.

What is autosave in WordPress?

While editing a post in WordPress, WordPress automatically saves a copy of your post content every 60 seconds. Every 60 seconds, you will notice that the phrase AutoSave and then the phrase Saved appear at the top of the post editing window without any intervention from you, and each post will have only one autosave copy.

Therefore, autosave in WordPress is a feature in the WordPress editor that saves the editor’s content automatically and at regular intervals, so that you do not have to press the save or refresh button manually.

The benefit of using the autosave feature is that if you close the edit tab of a post without saving it, the first thing you’ll see in the post editor during your next login is the autosaved version of the post.

WordPress uses your browser’s local storage feature if you’re editing your post offline. Even if your content is not saved in the database, WordPress will notify you if it finds an auto-save version of the post that is different from the copy of the current post, so that you can continue exactly where you left off.

WordPress follows a different approach to automatically saving published content than unpublished content. It will display a message to help you recover your work, but the message differs if you are working on a previously published article or page or if your work is still in draft or under review.

If you are editing an article that has not been published on the site (i.e. an article that is in draft or awaiting review) and an error occurs in the process of saving this article, you will see this message (the backup copy of this article in your browser is different from the version below) and below it you will see a link, click The Restore Backup button and when you click it, WordPress will automatically restore the autosave and you won’t need to do anything else.

If the article or page is already published, you will see this message (There is an auto-save for this article that is more recent than the version below) and below it is a link to view the auto-save as follows:

When you click on this link, you will be taken to the revision history screen as shown in the following image, where the autosave copy is saved as one of the revisions, but it is named AutoSave by followed by the name of the user, and it is highlighted in red to differentiate it from the rest of the other revisions.

That’s why you should click on the View AutoSave link and visit the main reviews page, and in order to restore your content you have to click on the Restore this autosave button at the top left of the reviews window and the problem will be solved.

This feature is automatically activated on your WordPress site, but you are free to enable or disable this feature on your site, and you can control it according to your requirements, as we will explain shortly.

What is the difference between autosave and revisions in WordPress?

It is worth noting that the auto-save feature differs from the similar reviews feature, but the reviews are not self-save as in the case of auto-save, but rather are created every time you press the Update , Save Draft , or Publish button.
A new review of the post is created every time you click on one of these buttons. This means that you will have multiple reviews and all of them will be added to a record that includes a group of reviews.

You can view all reviews for an article from the sidebar of the editor window as follows:

When you click on it, a window will appear that displays the review history. As we mentioned previously, it is the same window that appears when you click on the auto-save link, but here comparisons appear between each two successive review versions.

The reviews are saved behind each other so that every two consecutive reviews that you have saved can be compared. The revision saved before will have the phrase “Removed” written over it and it will be in red, and the revision saved immediately after it will have the phrase “Added” written over it and will be in green. At the top is a button titled Restore this review

Read more: Learn about the revision history of WordPress blogs and how to manage it professionally:

The reviews feature may not usually be supported in plugins and custom posts in WordPress. For example, the WooCommerce plugin does not support the use of reviews. This means that if you are making changes to one of your store’s products and something goes wrong in the saving process, this data will not be stored in a log. Reviews.
If the add-on does not support reviews, it will also not support the auto-save feature, which means that some of your data may be lost if the saving process is not done correctly.

How to change the autosave duration in WordPress

As a website owner, you may want to change the auto-save period in WordPress as you wish. For example, you may need to increase the time interval for each auto-save operation to ensure that your browser does not stop if your Internet connection is weak or your hosting resources are limited.

Or you may want to reduce the autosave interval so that your content is saved more frequently and at a faster pace to ensure that no content is lost due to a crash.

Autosave is usually controlled through the wp-config.php file, which is located in the root folder of your site and which controls all the basic settings of your WordPress site. In this file, you can define the autosave period for your website.

To do this, you must have access to and edit your WordPress site files . You can access the site files through the file manager in the hosting control panel, or through one of the FTP programs .

For example, to change the autosave period and make it happen every 5 minutes instead of 1 minute, edit the file wp-config.php and write the following code in it:

define(‘AUTOSAVE_INTERVAL’, 300 );

Note that the required time must be estimated in seconds (5 minutes equals 300 seconds), and you must also pay attention to the writing position within the file, as you can add this code in any position, but provided that it is before the next line in the file, otherwise the code you added will not work.

require_once ABSPATH . ‘wp-settings.php’;

Disable the autosave feature in WordPress

If you do not want to use the automatic saving feature for your site for any reason, you can disable it on your site and limit yourself to the manual saving process for publications. This can be done in two ways.

First method: By editing the wp-config.php file

Edit the file wp-config.php and add a long interval for the autosave procedure (eg make it a full day, 86400 seconds)

define(‘AUTOSAVE_INTERVAL’, 86400);

It is worth noting here that you can also disable autosave by disabling the WP_POST_REVISIONS property and writing the following in the wp-config.php file

define(‘WP_POST_REVISIONS’, false );

The problem with this method is that it will also disable post reviews, so it is not recommended if you want to keep the reviews feature on your site.

Second method: By editing the template functions file functions.php.

You can also disable the autosave feature in WordPress by taking advantage of hooks in WordPress . Add the following code to the template functions file functions.php

function disable_autosave() {
wp_deregister_script( ‘autosave’ );
}
add_action( ‘admin_init’, ‘disable_autosave’ );

In the previous code, the function disable_autosave was defined that disables automatic saving, and this function was linked with the action hook (disable_autosave) called admin_init, which is run before any other hook when the user reaches the site’s control panel.

What this code does is simply unregister the autosave script, which is usually written in the
post.php and post-new.php files in the wp-admin folder within the root folder of your site, which contains most of the files that operate your site’s admin control panel.

Conclusion

In today’s article, we learned about the autosave feature in WordPress, which makes the experience of editing posts and pages easier and more reliable. If your computer crashes or your browser fails while you are editing a post, there is no need to worry because through the feature you will be able to restore the last automatically saved revision with great ease.

Avatar photo
I am a young man who has been working in WordPress and e-marketing for 10 years. I would like to share my experience with you so that we can become professional in WordPress I will be happy to share the experience with you.