• Hey everyone –

    I am having a wee issue with referencing a conditional style sheet for IE.

    I’ve named the stylesheet “ie6.css” and want to add it to function.php, but every code I have tried does not work.

    Here is an example of one of the options I had been trying:

    function ie6_css() { ?>
    <!--[if lt IE 6]>
    <link rel="stylesheet" type="text/css" href="<?php echo bloginfo('stylesheet_directory') ?>/ie6.css" />
    <![endif]-->
    <?php }

    I have placed ie6.css in the theme’s root directory where the default css resides, and have changed some style info to test if it is actually being picked up by IE 6 and so far, have had no luck. I am fairly certain the issue is in the above code – and likely something I’ve messed up or neglected. I wasn’t sure what to put after the function statement, so I put “ie6_css” – not sure if that’s the main problem or not.

    Anyway, does anyone have an suggestions on which code to add to my function.php file to get IE to play nice? I really want to target all versions of IE prior to IE8 – the site seems fine in IE8, its just IE 6 & 7 that are the issues.

    Thank you!

    ~Deirdre

Viewing 4 replies - 1 through 4 (of 4 total)
  • Why are you trying to add the conditional comment to functions.php? It belongs in header.php – after your calls to the default css file.

    https://quirm.net/2009/06/29/wordpress-conditional-comment-css/

    Thread Starter DeirdreBunny

    (@deirdrebunny)

    Because the theme my client installed does not call up the file in the usual way. Regardless, I tried using the standard code (and many variations thereof) in the header to pull up the style sheet, and it had no effect. So, while searching, I found some information about that theme and it was recommended to use function.php to call the CSS.

    I just logged i to update people in case they had a similar question – I have finally met with success. I was using <!–[if lt IE 6]> not realizing that “lt” meant versions *less* than 6, not 6 itself – which is why IE6 was not showing any change. I replaced the 6 with: <!–[if lt IE 8]> to target versions prior to IE8, and that did the trick.

    Thanks for the link, I will keep it around for future use.

    FWIW, <!--[if lte IE 6]> = less than or equal to IE6.

    Thread Starter DeirdreBunny

    (@deirdrebunny)

    Thanks!

Viewing 4 replies - 1 through 4 (of 4 total)
  • The topic ‘Conditional CSS in function.php’ is closed to new replies.