Take the 2-minute tour ×
WordPress Development Stack Exchange is a question and answer site for WordPress developers and administrators. It's 100% free, no registration required.

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:

update_option('siteurl','http://www.federal-lawyer.com');
update_option('home','http://www.federal-lawyer.com');

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');
wp_enqueue_style('main-css');

outputs

<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);
wp_enqueue_script('flex_slider');
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
1  
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

1 Answer 1

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

 
discard

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.