Title: Conditional Tags
Last modified: August 19, 2016

---

# Conditional Tags

 *  [rize](https://wordpress.org/support/users/rize/)
 * (@rize)
 * [15 years, 3 months ago](https://wordpress.org/support/topic/conditional-tags-6/)
 * I found this code at wordpress codex, my question is how do I use this code?
 *     ```
       <?php
   
       if ( is_page('about') || $post->post_parent == '2' ) {
           // the page is "About", or the parent of the page is "About"
           $bannerimg = 'about.jpg';
   
       } elseif ( is_page('learning') || $post->post_parent == '56' ) {
           $bannerimg = 'teaching.jpg';
   
       } elseif ( is_page('admissions') || $post->post_parent == '15' ) {
           $bannerimg = 'admissions.jpg';
   
       } else {
           $bannerimg = 'home.jpg'; // just in case we are at an unclassified page, perhaps the home page
       }	
   
       ?>
       ```
   
 * How do I make it work with my <div>:
 * `<div id="image"><img src="BANNERHERE></div>`

Viewing 1 replies (of 1 total)

 *  [Christine Rondeau](https://wordpress.org/support/users/crondeau/)
 * (@crondeau)
 * [15 years, 3 months ago](https://wordpress.org/support/topic/conditional-tags-6/#post-1891839)
 * Try this:
 *     ```
       <div id="image">
       <?php
       if ( is_page('about') || $post->post_parent == '2' ) {
           echo '<img src="aboutbanner">';
   
       } elseif ( is_page('learning') || $post->post_parent == '56' ) {
           echo '<img src="learningbanner">';
   
       } elseif ( is_page('admissions') || $post->post_parent == '15' ) {
           echo '<img src="admissionbanner">';
   
       } else {
           echo '<img src="banner">';
       }	
   
       ?>
       </div>
       ```
   

Viewing 1 replies (of 1 total)

The topic ‘Conditional Tags’ is closed to new replies.

 * In: [Fixing WordPress](https://wordpress.org/support/forum/how-to-and-troubleshooting/)
 * 1 reply
 * 2 participants
 * Last reply from: [Christine Rondeau](https://wordpress.org/support/users/crondeau/)
 * Last activity: [15 years, 3 months ago](https://wordpress.org/support/topic/conditional-tags-6/#post-1891839)
 * Status: not resolved

## Topics

### Topics with no replies

### Non-support topics

### Resolved topics

### Unresolved topics

### All topics
