Take the 2-minute tour ×
WordPress Development Stack Exchange is a question and answer site for WordPress developers and administrators. It's 100% free, no registration required.

I've discovered a solution to an IE problem with a conditional comment. I only need it on the home page because I've isolated there with a class on only one image. Unfortunately, the comment causes me some problems on other pages so I need to limit the comment (and script) to function ONLY on the home page... here's what my comment looks like but it's not preventing from the other pages... I'm more designer than php guy but I'm trying...

<!--[if lt IE 9]><?php if(is_home() )?> 
    <script type="text/javascript" src="<?php bloginfo('template_url'); ?>/scripts/unitpngfix.js"></script>

Would certainly appreciate any help with this. Thanks much...

Jeff

share|improve this question

1 Answer 1

There are likely more elegant ways to do this sort of thing, but the quickest and easiest, using your code, would be to move the PHP conditional out of the CSS conditional. e.g. change this:

<!--[if lt IE 9]><?php if(is_home() )?> 
    <script type="text/javascript" src="<?php bloginfo('template_url'); ?>/scripts/unitpngfix.js"></script>

...to this:

<?php if( is_home() ) { ?> 
<!--[if lt IE 9]>
    <script type="text/javascript" src="<?php bloginfo('template_url'); ?>/scripts/unitpngfix.js"></script>
<?php } ?>

Also: aren't you missing the closing of the CSS conditional here?

<?php if( is_home() ) { ?> 
    <!--[if lt IE 9]>
    <script type="text/javascript" src="<?php bloginfo('template_url'); ?>/scripts/unitpngfix.js"></script>
    -->
<?php } ?>
share|improve this answer
    
Resolved! Very appreciative! ~Jeff –  Jeffrey Brown Aug 30 '11 at 19:04
    
Sorry, messed up my comments, but Chip, you were right, the close also needed to be in there. Thanks again. –  Jeffrey Brown Aug 30 '11 at 19:06

Your Answer

 
discard

By posting your answer, you agree to the privacy policy and terms of service.

Not the answer you're looking for? Browse other questions tagged or ask your own question.