I’m having a little problem with a wordpress installation. Basically, I have two servers: test.dev
and staging.dev
.
Set up (using the hosts file) and I’ve just copied the test.dev
WordPress installation over to the staging server. Works brilliant on my computer but on someone who doesn’t have test.dev
none of the CSS or images load. I looked into it and every path is still referencing test.dev
. I have this function in functions.php
:
function route_static_path($path)
{
echo get_template_directory_uri()."/".$path;
return true;
}
I thought the value for get_template_directory_uri()
might be set in wp-config.php
but it’s not. I’m really confused as to where this is coming from.
Caching is not your problem here. The home URL and site URL are stored in the
wp_options
table in your database. You can update them either by visiting the Settings > General page in your WordPress dashboard, or you can edit thesiteurl
andhome
option values directly in the database through an SQL query or a client such as phpMyAdmin.You can also override any site or home URL option stored in the database by adding the following code to your
wp-config.php
file:The above code will adjust depending on your domain.
It would appear this setting is for some reason stored in the database. I just ran this query:
I think this is a site migration problem. You need to everything that refers to
test.dev
to now bestaging.dev
in the database. You can use this script to help you with this task: http://interconnectit.com/products/search-and-replace-for-wordpress-databases/Just stumbled upon the same issue. Although I replaced the URL in all .php files and in the table
options
(siteurl and home), Chrome console still said that I try to load theme resources from another domain. I checked my database and found a cache option. I deleted it from my database. WordPress then creates a new entry using the updatedsiteurl
from database.