Make wordpress keep a smaller number of revisions
# wp-config.php
# limit post revisions
define('WP_POST_REVISIONS', 5);
# put the setting before this comment
/* That's all, stop editing! Happy blogging. */
Remove extra revisions
DELETE r FROM wp_posts r
INNER JOIN (
SELECT ID
FROM (
SELECT ID,
ROW_NUMBER() OVER (PARTITION BY post_parent ORDER BY post_date DESC) AS row_num
FROM wp_posts
WHERE post_type = 'revision'
) ranked
WHERE row_num > 5
) AS old_revisions
ON r.ID = old_revisions.ID;

0 Comments