20081014

清理WordPress的Revisions

Author:  WinkCategories:  Database, Softwares

由于Hosting的原因,好久未好好维护blog了。前段时间在制作LSDN的新Theme时发现,怎么突然数据库变得这么大!原来是WordPress从2.6版开始新增了Revisions功能,编辑文章时的页面中也多了版本维护的选项。莫非WordPress要转型成Wiki了?!像我等这样single-user使用WordPress的根本就不需要这个功能,而新版偏偏又默认开启并且后台没有可供关闭它的选项!

参考了“Disable and Turn Off Post Revisions Tracking in WordPress 2.6 or Above”、“How to Delete Existing WordPress Post Revisions Stored/Saved”以及“Delete Wordpress 2.6 Revisions”一些文章之后,明白了关闭该功能的方法是在“wp-config.php”文件中增加一行语句:

define('WP_POST_REVISIONS', false);

而即使禁用了,之前生成的数据仍然存在于数据库之中。关于如何清除Revisions功能历史数据,我觉得“Delete Wordpress 2.6 Revisions”这篇文章的方法更适合一些:

DELETE a,b,c
FROM wp_posts a
LEFT JOIN wp_term_relationships b ON (a.ID = b.object_id)
LEFT JOIN wp_postmeta c ON (a.ID = c.post_id)
WHERE a.post_type = 'revision'

需要注意的是,其中“wp_”的前缀需要改成符合实际情况的字符。

You can follow any responses to this entry through the RSS 2.0 feed. Responses are currently closed, but you can trackback from your own site.

One Response to “清理WordPress的Revisions”

  1. E-bike Says:

    ... [Trackback] ...

    [...] There you will find more Infos: lsdn.lynnstudio.net/delete-wordpress-revisions/ [...] ...

Back to Page Top