I'd been having trouble with the full domain name being written into the path of links and assets. Basically localhost:XXXX works fine, until I try to reach my site from a Virtual Box install of XP or in my local network, where the domain changes to computername.local:XXXX
I managed to solve this problem with a tip from http://www.deluxeblogtips.com/2012/06/relative-urls.html (code below)
The problem is that home_url which is referenced throughout my theme still returns the full domain, rather then just "/" as root. is there a way to filter home_url to do this? yes I could define('WP_HOME', '/' );
which will brute force the path, but causes other issues with feed readers and plugins - it also probably wont work with subdirectory installs.
thanks for your thoughts
add_action( 'template_redirect', 'rw_relative_urls' );
function rw_relative_urls() {
// Don't do anything if:
// - In feed
// - In sitemap by WordPress SEO plugin
if ( is_feed() || get_query_var( 'sitemap' ) )
return;
$filters = array(
'post_link',
'post_type_link',
'page_link',
'attachment_link',
'get_shortlink',
'post_type_archive_link',
'get_pagenum_link',
'get_comments_pagenum_link',
'term_link',
'search_link',
'day_link',
'month_link',
'year_link',
);
foreach ( $filters as $filter )
{
add_filter( $filter, 'wp_make_link_relative' );
}
home_url($path = '', $scheme = null);
}