Title: php if in wordpress
Last modified: August 19, 2016

---

# php if in wordpress

 *  Resolved [emiliss](https://wordpress.org/support/users/emiliss/)
 * (@emiliss)
 * [16 years, 5 months ago](https://wordpress.org/support/topic/php-if-in-wordpress/)
 * 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)

 *  [Robert Chapin](https://wordpress.org/support/users/miqrogroove/)
 * (@miqrogroove)
 * [16 years, 5 months ago](https://wordpress.org/support/topic/php-if-in-wordpress/#post-1308571)
 * <?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.
 *  [stvwlf](https://wordpress.org/support/users/stvwlf/)
 * (@stvwlf)
 * [16 years, 5 months ago](https://wordpress.org/support/topic/php-if-in-wordpress/#post-1308572)
 * 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](https://wordpress.org/support/users/emiliss/)
 * (@emiliss)
 * [16 years, 5 months ago](https://wordpress.org/support/topic/php-if-in-wordpress/#post-1308621)
 * 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](https://wordpress.org/support/users/emiliss/)
 * (@emiliss)
 * [16 years, 5 months ago](https://wordpress.org/support/topic/php-if-in-wordpress/#post-1308623)
 * 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](https://wordpress.org/support/users/emiliss/)
 * (@emiliss)
 * [16 years, 5 months ago](https://wordpress.org/support/topic/php-if-in-wordpress/#post-1308671)
 * 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.

 * In: [Fixing WordPress](https://wordpress.org/support/forum/how-to-and-troubleshooting/)
 * 5 replies
 * 3 participants
 * Last reply from: [emiliss](https://wordpress.org/support/users/emiliss/)
 * Last activity: [16 years, 5 months ago](https://wordpress.org/support/topic/php-if-in-wordpress/#post-1308671)
 * Status: resolved

## Topics

### Topics with no replies

### Non-support topics

### Resolved topics

### Unresolved topics

### All topics
