CSS Stylesheet linking wrong in WordPress across entire site

Ok, I have a feeling I’ve really done it this time. I’ve developed a WordPress site locally and then transferred it to my remote server. I did a search and replace on the database using the script.

Now, I go into my site on the remote server and the HTML is good, but the CSS stylesheet is not linking properly.

Read More

Here is how it appears when I view source:

<link rel="stylesheet" type="text/css" media="all" href="www.fairchildwebsolutions.com/jesusandg/wp-content/themes/Sky/style.css" />

Now when I click on the link in source, I am directed to this:

www.fairchildwebsolutions.com/jesusandg/www.fairchildwebsolutions.com/jesusandg/wp-content/themes/Sky/style.css

Obviously, one too many domain names in there, so the file cannot be found. My question now is, how do I go back and do a search and replace on this to remove the extra domain without messing things up even worse?

Related posts

Leave a Reply

4 comments

  1. <link rel="stylesheet" type="text/css" media="all" href="http://www.fairchildwebsolutions.com/jesusandg/wp-content/themes/Sky/style.css" />
    

    Without the http:// it thinks its a local link not direct.

    WordPress can also link to the stylesheet or theme directory:

    <link rel="stylesheet" type="text/css" media="all" href="<?php bloginfo( 'stylesheet_url' ); ?>" />
    

    Here is some more information on the function to call out the theme directory: http://codex.wordpress.org/Function_Reference/get_template_directory

  2. Add http:// to the beginning of your style href. Alternatively, since it appears you are on the same domain, simply modify the href to be the following:

    href="/jesusandg/wp-content/themes/Sky/style.css"
    

    The former is an absolute path. The latter is an absolute path relative to your domain root.

  3. Your stylesheet call is missing its http:// at the beginning of the href. This means the browser interprets it as a relative path not an absolute one and breaks the link.

    What does your stylesheet call say (probably in header.php)? It should be something like:

    <link rel="stylesheet" type="text/css" media="all" href="<?php echo get_stylesheet_directory_uri(); ?>/style.css" />
    

    The get_stylesheet_directory_uri() call returns the absolute path of the theme directory.

    If it’s not in header.php it’s probably referenced in functions.php using the wp_enqueue_script() function. Same deal – use get_stylesheet_directory_uri() or one of the several template tags that do the same thing and make sure that is used to build the url to the stylesheet rather than defining it explicitly.