Home > WP General > Customize WordPress Post Revisions

Customize WordPress Post Revisions

January 17th, 2010 Leave a comment Go to comments

In a default install of WordPress, each time you edit a post or page, WordPress will automatically save your previous posts/pages allowing the possibility of reverting to a previous version of that post or page. This is a cool feature, but it can get a little ridiculous when you have dozens of previous versions sitting below the post–and taking up space in your db. As you can see in the following screenshot, with just a couple of edits to this post, I’ve already racked-up 4 revisions…by the time I finish editing, I’ll probably have a dozen or so…

Each of those revisions requires a separate record in the db. So, although this is a cool feature, it can significantly add to db bloat.  If you don’t really care to have all those revisions sitting around, or if you want to limit the number, WordPress does provide an option to change the default behavior allowing you to either disable revisions completely or allowing you to limit the number of revisions saved. To make these changes you do need to edit your wp-config.php file directly…currently, there is no option for doing this in WP admin.

Disable Post Revisions

To completely disable the revisions feature, add (or if already present) edit the following code to your wp-config.php file. The word (false) disables this feature.

define('WP_POST_REVISIONS', false );

Specify the Number of Post Revisions

If you want to keep the revisions feature, but limit the number revisions saved, then use the same code as above, but change false to the number of revisions you want to keep. In the example below, WordPress will keep the latest 3 post or page revisions.

define('WP_POST_REVISIONS', 3);

Share and Enjoy:
  • PDF
  • Print
  • email
  • Facebook
  • MySpace
  • Google Bookmarks
  • StumbleUpon
  • del.icio.us
  • Technorati
  • Digg
  • Sphinn
  • Mixx
  • Blogosphere News
  • Slashdot
  • Yahoo! Bookmarks
  • Faves
  • Live
  • MSN Reporter
  • MyShare
  • Yahoo! Buzz
  • blogmarks
  • FSDaily
  • Reddit
  • Twitthis

Related posts:

  1. WordPress 2.9 Trash Feature — How to Customize In WordPress 2.9 one of the new features is...

  1. Phil
    January 27th, 2010 at 14:23 | #1

    Just what I was looking for. Thanks!

  2. January 28th, 2010 at 23:57 | #2

    Thank you very much, works great, and I have applied this trick.

  3. February 21st, 2010 at 13:58 | #3

    Figaro, you probably should wrap those defines in PRE or CODE tags, because if you just copy/paste in UTF-8 environment those single quotes will go into wp-config.php as is and feature will not work. Just experienced this myself and wanted to let you know. Also WP will remove all of the old extra revisions once you save the article.

  4. February 21st, 2010 at 18:05 | #4

    @Vagabond: Thanks for the tip.

  5. prash
    February 21st, 2010 at 22:17 | #5

    this doesn’t seem to work on version 2.9.2. is there another way for this version?

  6. February 22nd, 2010 at 09:27 | #6

    @prash: It should work…works on my install.

  7. March 12th, 2010 at 00:59 | #7

    You might also need to check the wp-settings.php file. Depending on where you put the new define statement, this file might override the define statement in the wp-config.php file.

  1. No trackbacks yet.
Get Adobe Flash playerPlugin by wpburn.com wordpress themes