I noticed recently that one of my WordPress sites had started skipping post numbers. It used to just go in order… 1, 2, 3 onward as expected. Suddenly post numbers were incrementing several at a time, seemingly randomly. What’s up with that?
I started looking around and found the database had multiple entries per post. A little more digging and I realized that WordPress 2.6 had added versioning (is “revisioning” a word?). Each time a draft was saved, WordPress would save it as a new entry with the post_type set to “revision” (versus “post” for the final version) and the database would increment the id by one. Mystery solved.
Versioning can be really valuable — it’s a key feature of content management systems and wikis — but for some of my blogs I only want my final version to be saved and available. So, how to turn it off?
In wp-config.php, simply add the following line to turn off revisions:
define('WP_POST_REVISIONS', false);
On a related note, autosaves can add extra posts in the database. A workaround is setting a high interval for autosaves, in wp-config.php:
define('AUTOSAVE_INTERVAL',600);
Once you have these changes in place you may remove revisions that have already been saved in the database by issuing the following command within mysql:
delete from wp_posts where post_type = "revision";
Before you do that, though, you may wish to list all the entries that are set as revisions:
select ID, post_title from wp_posts where post_type = 'revision';
And compare them to the entries set as posts:
select ID, post_title from wp_posts where post_type = 'post';