• Hi there,

    I hope this is the right place to post this question. It is more about PHP syntax. Although I need it for my theme ??

    I want to add IE specific stylesheets in the header of my theme. So not wanting to touch the original (Thematic) header.php I want to add a function that will do the job.

    My code looks like this

    function ie_styles() {
    echo "<!--[if IE]><link rel="stylesheet" type="text/css" href="all-ie-only.css" /><![endif]-->";
    }
    
    add_action( 'thematic_header','ie_styles',1 );

    and it breaks my theme. The function works if I only echo “Test” (for example).

    My only guess is that I am not correctly striking out characters within my echo statement?

Viewing 2 replies - 1 through 2 (of 2 total)
  • Hello Zane,

    Add the following function to the functions.php file of your child theme

    function ie_styles() {
        global $wp_styles;
        echo '<!--[if IE]>';
        wp_enqueue_style('ie_only', get_stylesheet_directory_uri() . 'all-ie-only.css');
        echo '<![endif]-->';
        $wp_styles->add_data( 'ie_only', 'conditional', 'IE' );
    }
    add_action( 'wp_enqueue_scripts','ie_styles');

    Hope this helps.

    Thanks

    Thread Starter Zane

    (@xane_777)

    Hi Sampression,

    mmm…seems like my approach was only a ‘little’ off ??

    Thank you very much! I will give this a try.

Viewing 2 replies - 1 through 2 (of 2 total)
  • The topic ‘echo IE conditional css in header’ is closed to new replies.