最新消息:雨落星辰是一个专注网站SEO优化、网站SEO诊断、搜索引擎研究、网络营销推广、网站策划运营及站长类的自媒体原创博客

How can I purge all post revisions except the latest 5?

programmeradmin2浏览0评论

I know I can use define('WP_POST_REVISIONS', 5); to limit future post revisions to 5, but how would I go about purging all existing revisions except the latest 5?

I know I can use define('WP_POST_REVISIONS', 5); to limit future post revisions to 5, but how would I go about purging all existing revisions except the latest 5?

Share Improve this question asked Sep 9, 2020 at 16:57 JonnyJonny 1456 bronze badges
Add a comment  | 

3 Answers 3

Reset to default 1

Please take database backup and run a below MYSQL query and check is this helpful:

DELETE FROM wp_posts WHERE post_type = "revision" AND ID NOT IN(SELECT ID FROM wp_posts WHERE post_type = 'revision' ORDER BY ID DESC LIMIT 5)

To limit the number of revision saved in the future, you can use

define('WP_POST_REVISIONS', 5 );

Every time you'll save a post, a maximum number of 5 revisions will be kept in the database and all the older ones will be removed.

This will, however, remove them only when saving the posts, so you may want to manually use @Yash solution the first time if you really have a huge dataset.

I just found this plugin that lets you specify how many revisions you wish to keep:

https://wordpress/plugins/rvg-optimize-database/

发布评论

评论列表(0)

  1. 暂无评论