How to handle WordPress post revisions

How to handle WordPress post revisions? Just add define( ‘WP_POST_REVISIONS’, 3 ); code in WordPress config.php to store limited post revisions.

What is post revisions

The WordPress revisions system stores a record of each saved draft or published update. The revision system allows you to see what changes were made in each revision by dragging a slider (or using the Next/Previous buttons). The display indicates what has changed in each revision – what was added, what remained unchanged, and what was removed. Lines added or removed are highlighted, and individual character changes get additional highlighting. Click the ‘Restore This Revision’ button to restore a revision.

The revisions page also includes a ‘compare any two revisions’ mode that allows you to compare any two individual revisions. In this mode, the slider has two handles, one representing the revision you are comparing from and one representing the revision you are comparing to. Drag the handles to see what has changed between any two specific revisions. Note: the ‘Restore This Revision’ button always restores the revision you are comparing to.

To return to the post edit screen without restoring a revision, click on the post title at the top of the page.

WordPress post revisions
WordPress

Set WordPress post revisions limit

Limit the number of posts revisions that WordPress stores in the database.

The wp_revisions_to_keep filter allows developers to easily alter how many revisions are kept for a given post.

Alternately, the limit can be set in wp-config.php:


define( 'WP_POST_REVISIONS', 3 );

WP_POST_REVISIONS

  1. true (default), -1: store every revision
  2. false, 0: do not store any revisions (except the one autosave per post)
  3. (int) > 0: store that many revisions (+1 autosave) per post. Old revisions are automatically deleted.