ThemeShaper Forums » Thematic

[closed]

Conditional Comments for IE

(6 posts)
  • Started 9 years ago by tmayo
  • Latest reply from sixfootjames
  • This topic is resolved
  1. tmayo
    Member

    where is the best place to insert conditional comments for IE version-specific CSS files?

    Thanks,
    Tim

    Posted 9 years ago #
  2. Hi Tim,

    I'd think some where after the stylesheet is called would work pretty well. So try filtering thematic_create_stylesheet() and adding the comment onto the end of it.

    function child_conditional_comment($thm_stylesheet) { 
    
    	$conditional_comment   = "\t" . '<!--[if IE 8]>';
    	$conditional_comment  .= 'Welcome to Internet Explorer 8.';
    	$conditional_comment  .= '<![endif]-->' . "\n\n";
    
    	$child_stylesheet = $thm_stylesheet . $conditional_comment;
    
    	return $child_stylesheet;
    }
    add_filter ('thematic_create_stylesheet','child_conditional_comment');

    -Gene

    Posted 9 years ago #
  3. tmayo
    Member

    Thanks for the reply Gene, I also found this which is a similar approach to what you outlined: http://themeshaper.com/functions-php-wordpress-child-themes/


    function childtheme_iefix() { ?>
    <!–[if lt IE 8]>
    <link rel="stylesheet" type="text/css" href="<?php echo bloginfo('stylesheet_directory') ?>/ie.css" />
    <![endif]–>
    <?php }
    add_action('wp_head', 'childtheme_iefix');

    Posted 9 years ago #
  4. Hi Guys,

    I have used the above example, thank you very much but it seems my conditional is still pulling through into FF. Could someone please take a look at this and let me know what I might be doing wrong?

    /*--------------------------------------------------- IE FIXES */
    function childtheme_iefix() { ?>
    <!--[if lt IE 8]>
    <link rel="stylesheet" type="text/css" href="<?php echo bloginfo('stylesheet_directory') ?>/ie.css" />
    <![endif]-->
    <?php }
    add_action('wp_head', 'childtheme_iefix');
    /*------------------------------------------------------------- */

    Many thanks

    Posted 7 years ago #
  5. james - tmayo's conditional comments aren't correct.... need !-- 2 hyphens and not !- one hyphen. i have edited your code and it should work now.

    Posted 7 years ago #
  6. Rookie mistake!!! Going back to my cave now! Thanks Helga!

    Posted 7 years ago #

RSS feed for this topic

Topic Closed

This topic has been closed to new replies.