How to Disable and Limit Post Revisions in WordPress

Categories Components, Posts, Tutorials
Disable and Limit Post Revisions in WordPress

WordPress saves revisions of each posts every 60 seconds to make the editing flow better. It allows the author to go through the old revisions of the post in case the author removed something and now wants to restore it.

While post revisions are useful, they take a lot of space in your database. For the users who do not want post revisions, they can simply disable or limit post revisions in WordPress with a few lines of code.

Disable/Limit Post Revisions in WordPress

Before WordPress 3.6.0, the only way to limit post revisions in WordPress was to use WP_POST_REVISIONS constant in wp-config.php file. Now you can use wp_revisions_to_keep filter to manage post revisions.

You can add the following code to the functions.php file of your theme to limit post revisions to 5:

It will limit number of post revisions to 5. Once reached 5, all the old post revisions will be deleted. What if you do not want post revisions at all? In that case, you can add the following code:

That will disable the post revisions feature and none of the revisions will be saved.

Leave a Reply

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