Title: Issues with IfElse Statement in Header
Last modified: August 21, 2016

---

# Issues with IfElse Statement in Header

 *  [TakeTheCann0lis](https://wordpress.org/support/users/takethecann0lis/)
 * (@takethecann0lis)
 * [12 years, 2 months ago](https://wordpress.org/support/topic/issues-with-ifelse-statement-in-header/)
 * I’ve tried doing this by page slug name and number, but neither seems to work.
   Any ideas?
 *     ```
       <?php if (is_front_page()) { ?>
   
       		<div class="header-background-image"></div>
   
       		<header id="header-global" role="banner">
   
       	<?php } elseif (is_single()) { ?>
   
       		<div id="post-header-override" class="header-background-image"></div>
   
       		<header id="header-post" role="banner">
   
       	<?php } elseif (is_page(22)) { ?>
   
       		<div id="post-header-override" class="header-background-image"></div>
   
       		<header id="header-post" role="banner">		
   
       	<?php } else { ?>
   
       		<div class="header-background-image-inner"></div>
   
       		<header id="header-global-inner" role="banner">
   
       	<?php } ?>
       ```
   

Viewing 2 replies - 1 through 2 (of 2 total)

 *  [The Grey Parrots](https://wordpress.org/support/users/greyparrots/)
 * (@greyparrots)
 * [12 years, 2 months ago](https://wordpress.org/support/topic/issues-with-ifelse-statement-in-header/#post-4774064)
 * Are you using a custom query or several loops on the header? Try to insert
 *  [catacaustic](https://wordpress.org/support/users/catacaustic/)
 * (@catacaustic)
 * [12 years, 2 months ago](https://wordpress.org/support/topic/issues-with-ifelse-statement-in-header/#post-4774074)
 * You should be able to figure this out with some simple de-bugging…
 * What does this show?
 *     ```
       <?php
           echo "<p>Page ID: '".$post->ID."', Front page: '".is_front_page ()."', Single: '".is_single ()."', Page 22: '".is_page (22)."'</p>";
       ?>
       ```
   
 * Look at the results of that and you’ll see what is and isn’t giving you the right
   results.

Viewing 2 replies - 1 through 2 (of 2 total)

The topic ‘Issues with IfElse Statement in Header’ is closed to new replies.

## Tags

 * [if else](https://wordpress.org/support/topic-tag/if-else/)
 * [php](https://wordpress.org/support/topic-tag/php/)

 * In: [Fixing WordPress](https://wordpress.org/support/forum/how-to-and-troubleshooting/)
 * 2 replies
 * 3 participants
 * Last reply from: [catacaustic](https://wordpress.org/support/users/catacaustic/)
 * Last activity: [12 years, 2 months ago](https://wordpress.org/support/topic/issues-with-ifelse-statement-in-header/#post-4774074)
 * Status: not resolved

## Topics

### Topics with no replies

### Non-support topics

### Resolved topics

### Unresolved topics

### All topics
