Why WP_POST_REVISIONS Doesn’t Work (Sometimes)

I wanted to clamp the edits on one of my WordPress blogs recently, and decided to use the trusty old WP_POST_REVISIONS entry, where you add the following to wp-config.php:

define('WP_POST_REVISIONS', 3);

…Somewhere before the require_once function:

require_once(ABSPATH.'wp-settings.php');

Sounds good right?

It didn’t work.

A quick check on the forums assured me of two things:

  1. I wasn’t alone in having this issue.
  2. A lot of people were annoyed (VERY ANNOYED) by this failure.

Basically, if you use a number like 3 it clamps – SHOULD CLAMP – revisions to a maximum of the last 3 (plus any autosaves) – and if you use false like this:

define('WP_POST_REVISIONS', false);

No edits are saved.

Trying options, I hit on what I think is the problem – Revision Control.

Simply put, if you have an old post with revisions already, adding this entry doesn’t always make them disappear automatically from the database, or clean them up (although it might hide them from view – just remove the entry and they pop back again).

Here’s the kicker: Repeatedly saving copies so as to ‘trigger’ cleanup won’t work either, UNLESS YOU CHANGE THE TEXT. Revision control doesn’t see a new copy unless there are changes, so cleanup is not triggered. Change a letter or two, save it, and old entries are finally trashed.

So basically:

  1. Add the WP_POST_REVISIONS entry to your wp-config.php file.
  2. Go to any article you want trimmed.
  3. Change something in it and save.
  4. Change it back and save (unless you like the changes).

Of course, if you have lots of posts with revisions, heave a sigh, and leave them be – the effort to revise each and every one is simply not worth it. Frankly, I think WP should come with the entry already in wp-config.php, and set to something like 5 or 10 by default – better yet, a configurable setting in Admin to change it AND clean up the database would work well…

SOME ITEMS YOU MIGHT ENJOY
Wordpress Survey Creator Plugin PLUS 1000+ Turnkey Websites Resale Rights
$3.95
End Date: Friday Jan-12-2018 15:41:21 PST
Buy It Now for only: $3.95
Buy It Now | Add to watch list
Turnkey Autos / Car Wordpress Blog Site For Sale!
$24.95 (0 Bids)
End Date: Wednesday Dec-20-2017 13:53:41 PST
Bid now | Add to watch list
87 ElegantThemes premium WordPress API KEY included Life time Licence worth $247
$9.00
End Date: Saturday Dec-16-2017 8:08:00 PST
Buy It Now for only: $9.00
Buy It Now | Add to watch list


One thought on “Why WP_POST_REVISIONS Doesn’t Work (Sometimes)

  1. I was suggested this blog by my cousin. I’m not sure whether this post is written by him as no one else know such detailed about my difficulty. You are wonderful! Thanks!

Leave a Reply

Your email address will not be published. Required fields are marked *