Support » Fixing WordPress » Question about linking stylesheets

  • Resolved bluedrag


    I’m trying to use a javascript file which automatically writes the browser vendor prefixes in front of some of the new CSS3 rules (it’s called cssFx.js you can find it at this URL ) It also gives support to IE6+ which is more important then the latter to me 🙂

    The thing is in order to use it you have to add a class to the link to your external stylesheet like so

    <link rel=”stylesheet” href=”effects.css” class=”cssfx”>

    and since wordpress uses it’s own template tag to link the main stylesheet I’m not sure how I would do this. Does anyone know? Is it really a bad idea to just write the above code in my header.php instead of using wordpress’s template tag to do the same?

Viewing 7 replies - 1 through 7 (of 7 total)
  • Depends a bit on your theme, but generally speaking you need to alter its header.php file. It’s usually best to create a child theme to do this if at all possible.

    It’s essential to use a child theme if you’re using either twentyten or twentyeleven as your theme.



    Yes I am using a child theme, but my question was can I link my stylesheet (style.css) using a standard html href as opposed to the wordpress template tag. The reason I need to do this is because of the third party js file I would like to use to give older versions of IE CSS3 support.


    Same answer.

    The style sheet is usually referenced something like this, in header.php:

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

    If you just wanted to add a class, for instance, you’d copy your parent theme’s header.php file to your child theme. Then you’d change the code above to read something like:

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

    Or if you wanted an entirely different stylesheet you’d do something like:

    <link rel="stylesheet" type="text/css" media="all" href="<?php bloginfo( 'stylesheet_directory' ); ?>/effects.css" class="cssfx" />

    Note the change to the bloginfo() parameter.



    Hmm, I don’t see that line of code in my header.php (I’m using basic2col as my parent theme)

    This is what I see, I think it’s pretty safe to say this line of php is generating the html href

    <?php basic2col_css() ?>

    Do you think replacing this line with your code would do the trick?

    Thanks for your help.

    Probably. Hard to say without access to the code. But you can try it for nothing. If it doesn’t work, you can always put it back.

    Another thing you might do is to look at the basic2col_css() function. I’d guess it’s in functions.php. If the theme has been well coded and it has the if ( ! function_exists() ) condition wrapped around it you will be able to override the function in your own theme’s functions.php file. Simply copy the existing function into your own functions.php and then modify it to suit.



    Ahhh thank you sir! I was able to add the class to basic2col_css() through functions.php just as you said. Much appreciated.

    The pleasure is all mine.


Viewing 7 replies - 1 through 7 (of 7 total)
  • The topic ‘Question about linking stylesheets’ is closed to new replies.