WordPress Development Stack Exchange is a question and answer site for WordPress developers and administrators. Join them; it only takes a minute:

Sign up
Here's how it works:
  1. Anybody can ask a question
  2. Anybody can answer
  3. The best answers are voted up and rise to the top

My site's url is set up to include www in settings -> general. I also put it at the very top of my functions.php:


However, when I use the get_template_directory_uri(); function it outputs the non-www URL when enqueuing stylesheets. Any ideas on why this may be happening?

for example, in functions.php

wp_register_style('main-css',  get_template_directory_uri() . '/css/main.css', array(), '1.0', 'all');


<link rel='stylesheet' id='main-css-css'  href='http://federal-lawyer.com/material/themes/fedlaw/css/main.css?ver=1.0' type='text/css' media='all' />

Interestingly, this doesn't happen for scripts enqueued in the functions.php file.

$java_script_url = get_template_directory_uri().'/js/';
wp_register_script('flex_slider', $java_script_url.'flexslider/jquery.flexslider-min.js', array('jquery'), '2.2.0', true);
share|improve this question
do you have any plugins or theme code which may be filtering style_loader_src or style_loader_tag? – Milo Dec 27 '13 at 2:09
It cannot output one thing in one place and another thing in another place without something else changing between the two. So if it's doing something different for scripts vs. styles, then you have code elsewhere that is altering it in between those two cases. – Otto Dec 27 '13 at 13:37
up vote 2 down vote accepted

Setting the siteurl and home should be done in wp-config.php.

  1. Remove them from functions.php.
  2. Add the below into wp-config.php (making sure they don't already exist).

    define( 'WP_HOME', 'http://www.federal-lawyer.com' );

    define( 'WP_SITEURL', 'http://www.federal-lawyer.com' );

share|improve this answer
The OP is using update_option in functions.php not define, but yes, the values should be defined in wp-config.php or set in the backend, not updated halfway through the WordPress boot. – s_ha_dum Dec 27 '13 at 15:23

Your Answer


By posting your answer, you agree to the privacy policy and terms of service.

Not the answer you're looking for? Browse other questions tagged or ask your own question.