Title: custom header for page
Last modified: August 19, 2016

---

# custom header for page

 *  Resolved [Lou](https://wordpress.org/support/users/purecreative/)
 * (@purecreative)
 * [15 years, 1 month ago](https://wordpress.org/support/topic/custom-header-for-page/)
 * Hi,
 * I am running the Twenty Ten theme and would like to set custom header image for
   different pages.
 * I found the following code which, if I understand it correctly, puts a header
   image if one is called through the custom field value and leaves the space blank
   otherwise:
 * `<div class="banner"> <?php if(get_post_meta($post->ID, 'banner', true)) : ?>
   <img src="<?php echo get_post_meta($post->ID, 'banner', true); ?>" /> <?php else:?
   > <?php the_title(); ?> <?php endif; ?> <div>`
 * This is almost what I need. I would like the code to look at the custom field
   value if there is one, and if there is none, leave the main banner up. Can it
   be done? If so, can someone please tell me how?
 * This is the banner code in my twenty ten header.php file
 * _[Code moderated as per the [Forum Rules](http://codex.wordpress.org/Forum_Welcome).
   Please use the [pastebin](http://wordpress.pastebin.com/)]_
 * Thanks in advance for reading and for your help.

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

 *  [Michael](https://wordpress.org/support/users/alchymyth/)
 * (@alchymyth)
 * [15 years, 1 month ago](https://wordpress.org/support/topic/custom-header-for-page/#post-2019341)
 * try to change this line:
 *     ```
       <img src="<?php header_image(); ?>" width="<?php echo HEADER_IMAGE_WIDTH; ?>" height="<?php echo HEADER_IMAGE_HEIGHT; ?>" alt="" />
       ```
   
 * into this section:
 *     ```
       <?php if(get_post_meta($post->ID, 'banner', true)) : ?> <img src="<?php echo get_post_meta($post->ID, 'banner', true); ?>" /> <?php else : ?>
       <img src="<?php header_image(); ?>" width="<?php echo HEADER_IMAGE_WIDTH; ?>" height="<?php echo HEADER_IMAGE_HEIGHT; ?>" alt="" />
       <?php endif; ?>
       ```
   
 *  Thread Starter [Lou](https://wordpress.org/support/users/purecreative/)
 * (@purecreative)
 * [15 years, 1 month ago](https://wordpress.org/support/topic/custom-header-for-page/#post-2019358)
 * That did it.
 * Thanks, Sweeper!!

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

The topic ‘custom header for page’ is closed to new replies.

 * 2 replies
 * 2 participants
 * Last reply from: [Lou](https://wordpress.org/support/users/purecreative/)
 * Last activity: [15 years, 1 month ago](https://wordpress.org/support/topic/custom-header-for-page/#post-2019358)
 * Status: resolved

## Topics

### Topics with no replies

### Non-support topics

### Resolved topics

### Unresolved topics

### All topics
