Title: Multiple banners PHP
Last modified: August 21, 2016

---

# Multiple banners PHP

 *  [sarahmghart](https://wordpress.org/support/users/sarahmghart/)
 * (@sarahmghart)
 * [12 years, 1 month ago](https://wordpress.org/support/topic/multiple-banners-php/)
 * Hi, I’m pretty new at PHP.
 * I have 6 pages that have custom banners I have added them like so:
 *     ```
       <?php if (is_page ( 'Homepage' ))  {echo '<img id="banner" src="banner1.png" />';  }
       <?php if (is_page ( 'About' ))  {echo '<img id="banner" src="banner2.png" />';  }
       ```
   
 * Now I want to make it so every other page or post on the site shows Banner1.png:
 * `<?php {echo '<img id="banner" src="http://www.anaverzone.com/wp-content/uploads/
   2014/04/banner1.png" />'; }`
 * But this creates 2 banners one over top of the other.
 * Not sure how to do this, suggestions would be appreciated 🙂
 * _[Moderator Note: Please post code & markup between backticks or use the code
   button. Your posted code may now have been permanently damaged by the forum’s
   parser.]_

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

 *  [esmi](https://wordpress.org/support/users/esmi/)
 * (@esmi)
 * [12 years, 1 month ago](https://wordpress.org/support/topic/multiple-banners-php/#post-4887472)
 *     ```
       <?php if (is_page ( 'About' ))  echo '<img id="banner" src="full_url_for/banner2.png" />';
       else echo '<img id="banner" src="full_url_for/banner1.png" />'; ?>
       ```
   
 *  Thread Starter [sarahmghart](https://wordpress.org/support/users/sarahmghart/)
 * (@sarahmghart)
 * [12 years, 1 month ago](https://wordpress.org/support/topic/multiple-banners-php/#post-4887495)
 * Hi Esmi!
 * That great but my problem is I have **6** banners so:
 *     ```
       <?php if (is_page ( 'Homepage' ))  {echo '<img id="banner" src="banner1.png" />';  }
       <?php if (is_page ( 'About' ))  {echo '<img id="banner" src="banner2.png" />';  }
       <?php if (is_page ( 'Work-with-me' ))  {echo '<img id="banner" src="banner3.png" />';  }
       <?php if (is_page ( 'Praise' ))  {echo '<img id="banner" src="banner4.png" />';  }
       <?php if (is_page ( 'Resources' ))  {echo '<img id="banner" src="banner5.png" />';  }
       <?php if (is_page ( 'Blog' ))  {echo '<img id="banner" src="banner6.png" />';  }
       ```
   
 * Thanks! 🙂
 *  Thread Starter [sarahmghart](https://wordpress.org/support/users/sarahmghart/)
 * (@sarahmghart)
 * [12 years, 1 month ago](https://wordpress.org/support/topic/multiple-banners-php/#post-4887543)
 * I figured it out, had to add an echo “” to the pages I wanted to keep separate!
 *     ```
       <?php if (is_page ( array ( 'about-contact', 'homepage', 'work-with-me', 'praise', 'free-resources', 'blog')))  echo ''; 
   
       else echo '<img id="banner" src="banner1.png" />'; ?>
       ```
   
 *  [Michael](https://wordpress.org/support/users/alchymyth/)
 * (@alchymyth)
 * [12 years, 1 month ago](https://wordpress.org/support/topic/multiple-banners-php/#post-4887558)
 * generally, you would use a `if / elseif / else` structure;
    [http://www.w3schools.com/php/php_if_else.asp](http://www.w3schools.com/php/php_if_else.asp)
 * (and open/close any php tags properly)
 * example:
 *     ```
       <?php
       if (is_page ( 'Homepage' ))  { echo '<img id="banner" src="banner1.png" />';  }
       elseif (is_page ( 'About' ))  { echo '<img id="banner" src="banner2.png" />';  }
       elseif (is_page ( 'Work-with-me' ))  { echo '<img id="banner" src="banner3.png" />';  }
       elseif (is_page ( 'Praise' ))  { echo '<img id="banner" src="banner4.png" />';  }
       elseif (is_page ( 'Resources' ))  {echo '<img id="banner" src="banner5.png" />';  }
       elseif (is_page ( 'Blog' ))  { echo '<img id="banner" src="banner6.png" />';  }
       else { echo '<img id="banner" src="http://www.anaverzone.com/wp-content/uploads/2014/04/banner1.png" />'; }
       ?>
       ```
   

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

The topic ‘Multiple banners PHP’ is closed to new replies.

## Tags

 * [Banners](https://wordpress.org/support/topic-tag/banners/)
 * [custom](https://wordpress.org/support/topic-tag/custom/)
 * [header](https://wordpress.org/support/topic-tag/header/)
 * [multiple](https://wordpress.org/support/topic-tag/multiple/)

 * In: [Fixing WordPress](https://wordpress.org/support/forum/how-to-and-troubleshooting/)
 * 4 replies
 * 3 participants
 * Last reply from: [Michael](https://wordpress.org/support/users/alchymyth/)
 * Last activity: [12 years, 1 month ago](https://wordpress.org/support/topic/multiple-banners-php/#post-4887558)
 * Status: not resolved

## Topics

### Topics with no replies

### Non-support topics

### Resolved topics

### Unresolved topics

### All topics
