Learn how to limit, delete or disable all post revisions in WordPress blogging platform. Code for manually removing WP revisions of post types in bulk without any plugin.
Ways to Manage Post Revisions in WordPress
There are many ways where you can disable, limit or delete WordPress post revisions. I have given the best of them below. Please select your best suited method as per your requirement.
Disable WordPress Revisions
To disable WordPress revisions completely, go to wp-config.php and add the line give below just before the lines /* That’s all, stop editing! Happy publishing. */ and save the wp-config.php file.
define('WP_POST_REVISIONS', false );
Limit WordPress/WP Revisions
If you want to limit the WordPress revisions to a maximum 10 numbers, then edit your wp.config file and put the following code just before the lines /* That’s all, stop editing! Happy publishing. */ and save the wp-config.php file.
define('WP_POST_REVISIONS', 10);
Delete all WordPress revisions via SQL
To remove or delete all current post revisions in WordPress (WP) via MySQL, MariaDB, or via phpMyAdmin, you can run the following SQL Query.
DELETE FROM wp_posts WHERE post_type = "revision";
Do not forget to take a database backup before trying the above SQL Query. Usually it is safe to execute this query, but just in case if you made any mistake, your backup will helps to restore WP (WordPress) to the original state.
Please note that if you installed WordPress using Automatic Installer like Softlacous in Cpanel or you might have changed the database table prefix from default value “wp_” to someother, then change the wp_posts value to your custom value. The default complete WordPress Table prefix code will look like below in your wp-config.php file.
$table_prefix
= 'wp_';
So your value in your wp-config.php file before executing the SQL query.
For an example let’s consider your table_prefix value looks like as given below in your wp-config.php file.
$table_prefix
= 'wp11_878';
ONLY then run the following SQL Query.
DELETE FROM wp11_878 WHERE post_type = "revision";
Advanced options for managing WordPress Post revisions
If you need advanced options for managing post revisions, then it is advised to use a plugin that makes your task easier. Check out my article on managing WordPress post revisions using an advanced plugin.
Comments and Discussions