wordpress中常用sql语句

联系:手机/微信(+86 17813235971) QQ(107644445)QQ咨询惜分飞

标题:wordpress中常用sql语句

作者:惜分飞©版权所有[未经本人同意,不得以任何形式转载,否则有进一步追究法律责任的权利.]

开启所有评论
UPDATE wp_posts
SET comment_status = ‘open’
WHERE post_status = ‘publish’;

关闭旧文章的留言
UPDATE wp_posts
SET comment_status = ‘closed’
WHERE post_date < '2009-01-01' AND post_status = 'publish' 删除所有的垃圾评论
DELETE FROM wp_comments
WHERE comment_approved = ‘spam’

删除所有文章修订版本(Revisions)以及它们的Meta数据
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_postmeta表
DELETE FROM wp_postmeta WHERE meta_key = ‘_wp_old_slug’;
DELETE FROM wp_postmeta WHERE meta_key = ‘_revision-control’;
DELETE FROM wp_postmeta WHERE meta_value = ‘{{unknown}}’;

写成shell脚本,添加表优化,可以使用crontab定时调用处理
执行shell

此条目发表在 Others 分类目录。将固定链接加入收藏夹。

wordpress中常用sql语句》有 1 条评论

  1. Chong.freeman 说:

    学习了。
    WP 的新版本中又加了几条 meta,不晓得有什么实质作用。