Discover in this tutorial how to limit the number of entries and page revisions that WordPress saves using a code snippet.
WordPress has an autosaving system that is great for avoiding scares. However, each revision takes up the same space as the article.
Therefore, if you have 20 revisions of each post you are increasing the size of the WordPress database considerably, which slows down the loading speed of the web.
Although there are plugins like WP-Optimize that are very practical for keeping the database optimized, in this case you only need to limit the number of revisions to make sure it doesn’t grow too much.
In addition, this preventive measure can be applied with a simple line of code:
Snippet to limit WordPress revisions
Add the following fragment somewhere before the line containing “require_once(ABSPATH….” in the wp-config .php file:
It’s as simple as that.
With this block only the last 5 versions of the entries and pages will be saved.
Are you interested in keeping a copy of a larger or smaller number of revisions? Change the snippet for a more convenient one.
As you can see, with one line of code you can limit the number of revisions of entries and pages that WordPress saves automatically.
It’s a simple and practical trick to keep the size of the database at bay and make sure it’s optimized.
I use it often. I hope you find it useful too.
Any questions? I read you in the comments.
And if you want to give me any suggestion for future tutorials, leave it in the contact form. Advantages of being a subscriber. 😉