How to Disable and Remove All Post Revisions in WordPress

Advertisement

Post revisions in wordpress is automatically created every time you edit and create a new post, it seems to be the history of all your created posts and pages, disabling post revisions is really helpful for single author blog and it save space in your database but for multiple authors blog I solely recommend keep revisions enable, for site admin to track posts changes or easily revert the old created post.

To disable post revisions add the code below into wp-config.php file of your theme.


define('WP_POST_REVISIONS', false);

The snippet above wouldn’t remove the old created posts and pages post revisions, to do that just execute this MySQL command.

I recommend doing a back-up first before executing the command below.


DELETE FROM wp_posts WHERE post_type = 'revision';

If you want to delete all related data, use the SQL query below


DELETE a,b,c
FROM wp_posts a
LEFT JOIN wp_term_relationships b ON (a.ID = b.object_id)
LEFT JOIN wp_postmeta c ON (a.ID = c.post_id)
WHERE a.post_type = 'revision';

If you don’t want to delete all posts revisions and only limit it on each post and pages, simply edit the above code to this one.


// 3 is the revisions limit on each post and pages.
define('WP_POST_REVISIONS', 3);

Don’t want to touch in PHPMyAdmin?

Don’t worry folks there is a plugin to remove existing posts revisions.

Download the WP-Optimize plugin and install and enable it on your blog.

Go to Dashboard > WP-Optimize and tick Remove all Post revisions. Click on the Process button and all the post revisions will automatically be deleted.

References and Credits

Michael Martin

Advertisement