WordPress Tutorial: Max Post Revisions

If you run a website with multiple editors generating a large number of articles, your WordPress database is likely to be inundated with post revisions, causing undue strain on the WordPress admin section and potentially resulting in slower page rendering times for users. Fortunately, there is an easy solution that can help you avoid these issues.

By adding the following line of code to your theme's functions.php file, you can restrict the number of post revisions that WordPress generates:

/**
 * Set the post revisions unless the constant was set in wp-config.php
 */
if (!defined('WP_POST_REVISIONS')) define('WP_POST_REVISIONS', 5);

This simple line of code defines the maximum amount of post revisions that WordPress will store in the database. In this case, we've set it to five, which should be sufficient to keep the database running smoothly.

It's worth noting that you can adjust the number to suit your particular needs. If you have a smaller website with fewer articles, you may not need as many revisions. On the other hand, if you have a larger website with a lot of content, you may need to increase the number to ensure that you have enough revisions to fall back on.

By taking the time to restrict your post revisions, you'll be able to maintain a healthy database that runs smoothly and efficiently. This, in turn, will help to ensure that your website remains responsive and user-friendly for your visitors.