• Resolved emiliss

    (@emiliss)


    Hi.

    I need to make a php if command (at least I think so), which first checks if the post in is a certain category. I guess in_category(); would do this.

    Then, if that’s true, it should check if the browser is IE7 or older, and if it is, print some text. I found a solution for that already:

    <!–[if lte IE 7]>
    <div>
    Displayed in IE 7 and lesser version of IE on IE 6 , IE 5 etc.
    </div>
    <![endif]–>

    How do I connect these to, or is it possible? I’m really new to php.

    Thanks for your answer.

Viewing 5 replies - 1 through 5 (of 5 total)
  • <?php if (in_category( 42 )) { ?>
    <!–[if lte IE 7]>
    <div>
    Displayed in IE 7 and lesser version of IE on IE 6 , IE 5 etc.
    </div>
    <![endif]–>
    <?php } ?>

    … where 42 is the category ID number.

    wrap your IE7 code in a IF PHP statement so its only included when the PHP conditions you specify are true. In this code, the test to see if this is IE7 or less won’t even appear in the HTML if the post is not in category 7

    <?php if ( in_category(7) ) { ?>
    <!--[if lte IE 7]>
    <div>
    Displayed in IE 7 and lesser version of IE on IE 6 , IE 5 etc.
    </div>
    <![endif]-->
    <?php } ?>
    Thread Starter emiliss

    (@emiliss)

    Hi again, thanks for your answers.

    This still doesn’t seem to work, I’m trying to use it in archive page template, but is that a wrong place to do so?

    Thread Starter emiliss

    (@emiliss)

    Correction: I’m using it in archive.php, since I have pages where I want to show posts from a single category, and in one of those categories I would like to add the above code in each post.

    Thread Starter emiliss

    (@emiliss)

    Ah, silly me. I had a wrog cat ID. Silly me.

    Thanks guys!

Viewing 5 replies - 1 through 5 (of 5 total)
  • The topic ‘php if in wordpress’ is closed to new replies.