Wordpress没有反映数据库的更改


Wordpress not reflecting changed of the database

当我将网站移动到另一个文件夹(从/dev/到/)时,问题就开始了。我已经浏览了整个数据库,以便将所有硬编码的/dev/更改为/,但我仍然注意到wordpress在某种程度上仍然使用旧值。

基本上,网站使用的信息已经不存在了。我检查了我自己和服务器的缓存,它们似乎都很干净(服务器似乎甚至没有这个功能)。

所以,我很失落。。。

当您移动wordpress安装时,您需要在整个数据库中更改网站URL。要做到这一点,您需要通过PHPMyAdmin导出当前数据库,然后使用以下工具:

http://interconnectit.com/products/search-and-replace-for-wordpress-databases/

对整个数据库进行搜索和替换。

搜索:www.yourwebsite.com/dev

替换为:www.yourwebsite.com

然后导入新数据库,通过wp-admin打开Wordpress网站并重新保存永久链接。

在数据库中运行此查询

set @oldurl = 'http://oldwp-url.com', @newurl = 'http://newwp-url.com';
UPDATE wp_options SET option_value = replace(option_value, @oldurl, @newurl) WHERE option_name = 'home' OR option_name = 'siteurl';
UPDATE wp_posts SET guid = REPLACE (guid, @oldurl, @newurl);
UPDATE wp_posts SET post_content = REPLACE (post_content, @oldurl, @newurl);
UPDATE wp_posts SET post_content = REPLACE (post_content, CONCAT('src="', @oldurl), CONCAT('src="', @newurl));
UPDATE wp_posts SET guid = REPLACE (guid, @oldurl, @newurl) WHERE post_type = 'attachment';
UPDATE wp_postmeta SET meta_value = REPLACE (meta_value, @oldurl, @newurl);