Title: Conditional tag help
Last modified: August 19, 2016

---

# Conditional tag help

 *  [Jonas Grumby](https://wordpress.org/support/users/ss_minnow/)
 * (@ss_minnow)
 * [17 years, 1 month ago](https://wordpress.org/support/topic/conditional-tag-help/)
 * I’m trying to write some conditional tag code so that I can show different banner
   images on different pages of a site. I started with this, to show a different
   header on the “disclaimer” page:
 *     ```
       <?php
         if (is_page("disclaimer")) {
         echo "<div id="header" style=" background:url('<?php bloginfo('url'); ?>/wp-content/themes/themename/images/top2.jpg') no-repeat bottom; ">";
         } else {
          echo "<div id="header" style=" background:url('<?php bloginfo('url'); ?>/wp-content/themes/themename/images/top.jpg') no-repeat bottom; ">";
         }
       ?>
       ```
   
 * The error message I’m getting is:
 * `Parse error: syntax error, unexpected T_STRING, expecting ',' or ';' in /home/
   myfoldername/public_html/1/wp-content/themes/themename/header.php on line 31`
 * Line 31 is the first of the two “echo” lines, and it does end with a semi-colon,
   so I’m not sure what I’m doing wrong.
 * If I get rid of the conditional stuff and just have
 * `<div id="header" style=" background:url('<?php bloginfo('url'); ?>/wp-content/
   themes/themename/images/top.jpg') no-repeat bottom; ">`
 * It works fine but then of course it displays the same header graphic on every
   page.
 * myfoldername and themename are replacements of the real names for the purposes
   of this example. In reality, they are both something else.
 * Thanks

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

 *  [Michael Fields](https://wordpress.org/support/users/mfields/)
 * (@mfields)
 * [17 years, 1 month ago](https://wordpress.org/support/topic/conditional-tag-help/#post-1063893)
 * Your php code is wrong – you have nested your `<?php ?>` blocks as well as put
   a function that prints a string inside of a string. Please try the following 
   code:
 *     ```
       <?php
         if (is_page("disclaimer")) {
         echo '<div id="header" style="background:url(' .  get_bloginfo('url') . '/wp-content/themes/themename/images/top2.jpg) no-repeat bottom; ">';
         } else {
          echo '<div id="header" style="background:url(' . get_bloginfo('url') . '/wp-content/themes/themename/images/top.jpg) no-repeat bottom; ">';
         }
       ?>
       ```
   
 *  Thread Starter [Jonas Grumby](https://wordpress.org/support/users/ss_minnow/)
 * (@ss_minnow)
 * [17 years, 1 month ago](https://wordpress.org/support/topic/conditional-tag-help/#post-1063964)
 * Excellent, thank you. Ultimately there will be about 5 pages that will each have
   their own header graphic and also a default header graphic for posts, search 
   results, etc. but I wanted to get one page to work first.
 * I’m pretty new to PHP scripting (obviously) and until now have been a code hacker
   rather than a code writer. I guess everyone has to start somewhere.
 *  [Michael Fields](https://wordpress.org/support/users/mfields/)
 * (@mfields)
 * [17 years, 1 month ago](https://wordpress.org/support/topic/conditional-tag-help/#post-1063968)
 * No problem skipper!

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

The topic ‘Conditional tag help’ is closed to new replies.

## Tags

 * [conditional](https://wordpress.org/support/topic-tag/conditional/)
 * [hacks](https://wordpress.org/support/topic-tag/hacks/)
 * [tags](https://wordpress.org/support/topic-tag/tags/)
 * [Themes](https://wordpress.org/support/topic-tag/themes/)

 * 3 replies
 * 2 participants
 * Last reply from: [Michael Fields](https://wordpress.org/support/users/mfields/)
 * Last activity: [17 years, 1 month ago](https://wordpress.org/support/topic/conditional-tag-help/#post-1063968)
 * Status: not resolved

## Topics

### Topics with no replies

### Non-support topics

### Resolved topics

### Unresolved topics

### All topics
