简体   繁体   English

WordPress - 主题从与站点URL不同的URL加载CSS

[英]WordPress - a theme loads CSS from a different URL than the Site URL

Yesterday I changed both my Home URL and Site URL to a new value (let's call it "address 2"). 昨天我将我的主页URL和站点URL更改为新值(让我们称之为“地址2”)。 It changed perfectly, no problems were present. 它变化很好,没有问题。 Today I tried accessing the website and found that I can't do it, so in wp-config.php I restored those URLs to previous values (let's call it "address 1"). 今天我尝试访问该网站,发现我无法做到,所以在wp-config.php我将这些URL恢复为以前的值(让我们称之为“地址1”)。 It worked and loaded the website, but CSS and images weren't loading at all. 它工作并加载了网站,但CSS和图像根本没有加载。

I looked up this problem in the Firebug and saw that theme files (images and CSS) are being loaded from the new address (address 2) I specified yesterday, but the back-end and the HTML are loading from the old one (address 1). 我在Firebug中查找了这个问题,看到主题文件(图像和CSS)是从我昨天指定的新地址(地址2)加载的,但后端和HTML是从旧地址加载的(地址1) )。

I have no idea what is going on. 我不知道发生了什么事。

Pictures: Current Site URL and Home URL settings: 图片:当前网站网址和主页网址设置: 当前设置

The website works with address 1, though it's not loading CSS and images: 该网站使用地址1,但它没有加载CSS和图像: 网站有效

Website is trying to load CSS from address 2, I don't know why: 网站正试图从地址2加载CSS,我不知道为什么: 样式表的地址错误

Could you please help me with that? 你能帮帮我吗? It's very important for my work. 这对我的工作非常重要。

You could also use the built in update function. 您还可以使用内置更新功能。 You'll need to modify your functions.php file with the following, then update (afterwards you can remove this from the functions.php again): 您需要使用以下内容修改functions.php文件,然后更新(之后您可以再次从functions.php中删除它):

update_option('siteurl','http://www.new-site-address.com');
update_option('home','http://www.new-site-address.com');

You can find more information about Moving Wordpress Sites here: http://codex.wordpress.org/Moving_WordPress 您可以在此处找到有关移动Wordpress站点的更多信息: http//codex.wordpress.org/Moving_WordPress

Although jme11's solution didn't fix the problem it helped me to find a solution to it. 虽然jme11的解决方案没有解决问题,但它帮助我找到了解决方案。 I had to set the relocation flag, after which you can log in from any valid address to wp-login.php file, and WordPress will set the SiteURL and HomeURL to the address you typed in the browser. 我必须设置重定位标志,之后您可以从任何有效地址登录到wp-login.php文件,WordPress会将SiteURL和HomeURL设置为您在浏览器中键入的地址。

I had to add define('RELOCATE',true); 我不得不添加define('RELOCATE',true); just before the line informing about the end of the usable part of the document. 在行之前通知文档可用部分的结束。

Thank you guys. 感谢大伙们。

If it doesn't change in the theme, that's strange. 如果它没有改变主题,那很奇怪。 I've never had that before. 我以前从来没有这样做过。

But I did have that problem of migrating WP sites to a new home with lots of broken links afterwards. 但我确实遇到了将WP站点迁移到新家的问题,之后会有大量断开的链接。 This is because WP saves links inside eg posts in the database and usually won't change them even if it's pointing to this very WP installation. 这是因为WP将链接保存在例如数据库中的帖子中,即使它指向这个非常WP的安装,也通常不会更改它们。

What I'd try is downloading a backup SQL file of the whole database WordPress uses (for example, with phpMyAdmin) and then run a search for http://xxx.xxx.183.18:8001/ (whatever your WP URL was before). 我尝试下载WordPress使用的整个数据库的备份SQL文件(例如,使用phpMyAdmin),然后运行搜索http://xxx.xxx.183.18:8001/ (无论您之前的WP URL是什么) 。 If you get any hits, run a bulk search-and-replace to exchange the old IP with the new one, save the SQL file, then import it into a new database and let WP use that new database. 如果您获得任何匹配,请运行批量搜索和替换以将旧IP与新IP交换,保存SQL文件,然后将其导入新数据库并让WP使用该新数据库。

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM