I like to develop locally on localhost, then push everything to a testing server. Both localhost and my testing server are using the same database. The only problem is get_template_directory() returns my testing server path.
Can I use .htacess or something else to return the corresponding local/live path from get_template_directory()?
I use a variation of a method suggested by Mark Jaquith in his WordPress Skeleton setup .
The idea of this is that by adding the following to the top of your wp-config.php file:
you can create a
local-config.php
file that can be used to specify separate settings for local development. As long as you don’t add this file into your source repository then it won’t be present when you deploy to the staging/production servers and the settings in the standard wp-config.php file will be used instead.You could then filter
theme_root
depending on the state of the WP_LOCAL_DEV constant, or specify different constants in the local config file itself, e.g.Hope that helps.
I found that you can define the site in wp-config.
I added the following to wp-config.php:
Now all links and images are served with correct paths.