How to remove in the wordpress database all posts revisions except the last three?

You can prevent more than three revisions from being saved to the database in the future by adding this line to your wp-config.php file:

define( 'WP_POST_REVISIONS', 3 );

That line should limit new posts to three revisions, but it won’t go through your database and clean it up.

The SQL snippet that you found for deleting old revisions from the WordPress database has problems, which you can read about in this thread on WordPress.org. The thread outlines the problems, and offers alternatives. The thread also reviews some plugins that will do this for you.

Leave a Comment