Everything About WP Auto-Save and Post Revision

WordPress as a Content Management System has incorporated multiple features in the recent past in order to please webmasters. Although most of these features have received critical appreciation, at the end of the day it is the general user who ends up grumbling at some of them because they seem to take control of their day-to-day actions. Two such features that have received enough bashing are WordPress Auto-Save and WordPress Post-Revising. These are more or less interconnected with each other and the codes that control them are capable enough to turn off any average webmaster.

This discussion will throw more light on these two features so that you don’t grow prematurely grey when they start controlling your activities. Hold on as we are in for a treat here.

Everything about WP Auto-Save and Post Revision


<

WordPress AutoSave

Let us start with the less complex WordPress AutoSave feature. It was introduced as a default WordPress feature in version 2.1 and since then it has stuck around like most of the WordPress features. As goes with the name, WordPress AutoSave regularly saves the current version of your post in your WordPress database for worst case scenarios. The time period that is followed by default by WordPress AutoSave is 60 seconds though it can be changed and below I will tell you how you change it.

Change WordPress AutoSave Time Interval

You will have to insert the below line in your wp-config.php file in order to control the default WordPress AutoSave Time Interval:

define('AUTOSAVE_INTERVAL', 300); // where 300 is the time period in seconds

You can edit the number 300 as per your convenience.

How to Disable WordPress AutoSave Feature

If you are amongst those WordPress webmasters who just don’t want to see the WordPress AutoSave feature hogging their screens then you will have to push the below code into your theme’s functions.php:

function disable_autosave() {
	wp_deregister_script('autosave');
}
add_action('wp_print_scripts','disable_autosave');

Did AutoSave Work?

There will be times when you will click on the Save Button assuming that in case of any failures WordPress AutoSave will be there to watch your back. What if in such scenarios WordPress AutoSave fails to “actually” save your data? Assuming that the page failed to load after you clicked the Save Button and the WordPress AutoSave didn’t work then you will be standing in the middle of nowhere. Your hours of hard work will be lost. Poof!

In such cases it is good to understand the minute details of WordPress AutoSave so that you know if AutoSave is working or playing illusionary games with you. So, please understand that your AutoSave hasn’t worked unless you see a “Post Draft Updated” status above your post-editing panel. In case you do not see such an update, be rest assured that the AutoSave feature might just fool you. This might not be true in all cases but why take risk?

How to Backup a Post Before Saving

WordPress AutoSave

Sincerely speaking, losing hours of genius content just because of a stupid AutoSave failure can be very irritating. In order to overcome such hiccups one must backup their content before hitting the Save Button or the Publish Button.

See, I am not saying that this will help you every time but at times when AutoSave fails or the next page fails to load then such backup strategies prove to be very handy. Below are the simple steps that you must follow before you hit the Save Button or Publish Button:

Switch to HTML mode in your WordPress post-editing panel and hit CTRL+A. This will select the complete post along with necessary HTML tags.

Paste the copied text as is in a notepad and save it somewhere. Hit the Save Button or Publish Button and if any failure occurs then use your backed up content.

WordPress Post Revision

WordPress introduced the Post Revision feature from WordPress 2.6 onwards. Since then an uncountable number of revisions have been created in various WordPress databases around the internet with (or without) the knowledge of webmasters. Believe it or not, but it is true. WordPress Post Revision feature is enabled by default in any WordPress installation and this continuously creates revisions of posts in your WordPress database which, of course, uses database resources.

Compare Revisions

I agree that the WordPress Post Revision feature must have been available as an option via the Dashboard and disabled by default but the reality is completely opposite so we will have to take matters in our own hands.

How to Disable WordPress Post Revisions

Before we dig deep into the WordPress Post Revision feature, I will tell you how to disable the same so that those who really don’t want to read more can use this trick and move on.

Add the below line in your wp-config.php file and Post Revisions will never haunt you:

define('WP_POST_REVISIONS',false);

Limit the Number of WordPress Post Revisions

On the lenient side, if you prefer to limit the number of post revisions instead of disabling it completely then push the below piece of code in wp-config.php file:

define('WP_POST_REVISIONS',3);

Delete all Leftover Post Revisions from WordPress Database

This one is interesting and important. Michael Ambrosio was pretty much disappointed with the WordPress Post Revisions already left in his WordPress database and wanted to clean them all. Thanks to him, the below query will clean up your database with any age old WordPress Post Revisions:

DELETE a,b,c
FROM wp_posts a
LEFT JOIN wp_term_relationships b ON ( a.ID = b.object_id)
LEFT JOIN wp_postmeta c ON ( a.ID = c.post_id )
LEFT JOIN wp_term_taxonomy d ON ( b.term_taxonomy_id = d.term_taxonomy_id)
WHERE a.post_type = 'revision'
AND d.taxonomy != 'link_category';

If you are not sure where exactly you need to run the above query then the below steps might be of some help:

Log into your phpMyAdmin panel. Your hosting provider (or your hosting account’s control panel) should give you the requisite information.

Look for an SQL tab that will switch you to the SQL query box. Paste the above query into that box and hit Go. Lastly, get in touch with your hosting provider if you are still not sure about your phpMyAdmin credentials.

NOTE: Please backup your WordPress database before you try any queries in your WordPress database.

Plugins to Control Post Revisions

Enough of codes, now let us check out a list of WordPress plugins that will help you take control of the WordPress Post Revision feature without altering any of your WordPress files:

  • Revision Control – This plugin will control the maximum number of revisions that are saved for posts and pages. You can disable WordPress revisions using this plugin itself.
  • WP-CMS Post Control – This plugin was actually designed to control the permissions user groups will enjoy in WordPress post editor. Accompanying it is the handy WordPress Post Revision feature which lets you control the number of post revisions that you want for each post.
  • Better Delete Revision – Very neat plugin that will help you delete the redundant post revisions from your WordPress database. It helps in reducing the WordPress Database size and optimizes its performance.
  • Revisionary – Unique plugin that helps users submit changes to content that is already published. These “revisions” can be reviewed by an editor and pushed live if required. This can prove to be handy for blogs with multiple writers who keep looking for important updates into articles that are already live.
  • Cleanup WordPress – This plugin will clean up your WordPress database with unwanted content like spam comments and various revisions that are no longer of any use.
  • Post Revision Display – This plugin will display an interactively styled differences/changes to a post using its various revisions available.
  • Revision Removal – Another plugin that will optimize your WordPress database by removing unwanted revisions. Again, this will optimize your WordPress Database.

Conclusion

Amazingly, I had never used the WordPress revisions feature until the idea for this article popped up. Similarly, I don’t think that WordPress AutoSave has ever helped me. Somehow, I always backup my content (as described earlier) before hitting the Publish Button. Let me know your experiences with WordPress AutoSave and WordPress Post Revision.

Opinions expressed in this article are those of the author and not necessarily those of Onextrapixel.