删除所有未使用的标签
DELETE a,b,c FROM wp_terms AS a LEFT JOIN wp_term_taxonomy AS c ON a.term_id = c.term_id LEFT JOIN wp_term_relationships AS b ON b.term_taxonomy_id = c.term_taxonomy_id WHERE c.taxonomy = 'post_tag' AND c.count = 0
删除所有文章修订版本(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'
更改WordPress地址和首页地址
UPDATE wp_options SET option_value = replace(option_value, 'http://www.旧网址.com', 'http://www.新网址.com') WHERE option_name = 'home' OR option_name = 'siteurl'
更改文章的GUID
UPDATE wp_posts SET guid = REPLACE (guid, 'http://www.旧网址.com', 'http://www.新网址.com')
更改正文中的链接地址
UPDATE wp_posts SET post_content = REPLACE (post_content, 'http://www.旧网址.com', 'http://www.新网址.com')
更新文章的Meta值
UPDATE wp_postmeta SET meta_value = REPLACE (meta_value, 'http://www.旧网址.com', 'http://www.新网址.com')
重设Admin密码
UPDATE wp_users SET user_pass = MD5( 'new_password' ) WHERE user_login = 'admin'
重设admin的用户名
UPDATE wp_users SET user_login = 'newname' WHERE user_login = 'admin'
将作者a的文章全部转移到作者b
UPDATE wp_posts SET post_author = 'b' WHERE post_author = 'a'
删除文章的meta标签
DELETE FROM wp_postmeta WHERE meta_key = 'your-meta-key'
导出所有评论中的邮件地址
SELECT DISTINCT comment_author_email FROM wp_comments
删除所有的Pingback
DELETE FROM wp_comments WHERE comment_type = 'pingback'
删除所有的垃圾评论
DELETE FROM wp_comments WHERE comment_approved = 'spam'
禁用所有激活的插件
UPDATE wp_options SET option_value = '' WHERE option_name = 'active_plugins'
罗列所有未使用的Meta标签
SELECT * FROM wp_postmeta pm LEFT JOIN wp_posts wp ON wp.ID = pm.post_id WHERE wp.ID IS NULL
关闭旧文章的留言
UPDATE wp_posts SET comment_status = 'closed' WHERE post_date < '2009-01-01' AND post_status = 'publish'
更新留言者的网址
UPDATE wp_comments SET comment_author_url = REPLACE( comment_author_url, 'http://旧网址.com', 'http://新网址.com' )
更新正文内所有的’target=”_blank”‘为’rel=”nofollow”‘
UPDATE wp_posts SET post_content = REPLACE (post_content, 'target="_blank', 'rel="nofollow')
删除未使用的Meta标签
DELETE pm FROM wp_postmeta pm LEFT JOIN wp_posts wp ON wp.ID = pm.post_id WHERE wp.ID IS NULL
删除重复的自定义字段(Custom Fields)
delete from wp_postmeta
where meta_id in (
select *
from (
select meta_id
from wp_postmeta a
where a.meta_key = 'views'
and meta_id not in (
select min(meta_id)
from wp_postmeta b
where b.post_id = a.post_id
and b.meta_key = 'views'
)
) as x
);
更改文章自定义字段的名称
UPDATE `wp_postmeta` SET `meta_key` = '新名称' WHERE `meta_key` = '旧名称';