【WordPress】批量修改文章内容信息-通过SQL数据库

我改变了Permalink,从http://zi-jin.com/?p=* 变成了 http://zi-jin.com/archives/* (当然,前面那种格式仍然可以访问,只是默认格式变了)

结果很多图片变成了叉烧包,因为文章中引用图片的地址是相对地址
src=”wp-content/uploads/…”
如果是以前的格式,就会变成http://files.zi-jin.com/uploads/…
而现在全部变成了

http://zi-jin.com/archives/wp-content/uploads/…

如果你去一个一个链接修改,那我不得不佩服你的耐性。
现在,让我给你解脱吧:
进入phpMyadmin
(或者下载wp-DBManager插件,进入后台“Run SQL Query”)
输入:

1
update `wp_posts` set `post_content` = replace(`post_content`, 'wp-content', 'http://zi-jin.com/wp-content');

运行命令,搞定。


Leave a Reply

Your email address will not be published. Required fields are marked *

*

You may use these HTML tags and attributes: <a href="" title=""> <abbr title=""> <acronym title=""> <b> <blockquote cite=""> <cite> <code> <del datetime=""> <em> <i> <q cite=""> <strike> <strong>