Title: Header Includes
Last modified: August 19, 2016

---

# Header Includes

 *  [rob0210](https://wordpress.org/support/users/rob0210/)
 * (@rob0210)
 * [18 years, 2 months ago](https://wordpress.org/support/topic/header-includes/)
 * Hi all,
 * I have a little issue i’m hoping to get resolved.
 * Its all about header includes.
 * With my set up I have a header which is to include different header images dependent
   on which page of the site your on. I only wanted to call this once hence why 
   I placed it in the header.
 * I have in my header.php for eg:
 *     ```
       if $thispage = ('Home'); { include ('headerimage1.php');
       }
       elseif $thispage = ('Blog'); { include ('headerimage2.php');
       }
       ```
   
 * Then above my header call on each template page if have:
 * `$thispage = 'Home';`
 * Unfortunately they do not seem to be called through… the code is right as I have
   used it on a none WP website.
 * Now I have tried the includes in each template page and they do work but It isn’t
   really ideal as I would rather only change 1 page than 20!
 * has anyone else had any issues with this? or any suggestions… I can supply more
   info if needed.

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

 *  Thread Starter [rob0210](https://wordpress.org/support/users/rob0210/)
 * (@rob0210)
 * [18 years, 2 months ago](https://wordpress.org/support/topic/header-includes/#post-723987)
 * This is driving me mad… wordpress does allow php code to come before the header
   is called right?
 * I really cant see what the issue is!… Any help would be really great
 *  Thread Starter [rob0210](https://wordpress.org/support/users/rob0210/)
 * (@rob0210)
 * [18 years, 2 months ago](https://wordpress.org/support/topic/header-includes/#post-723992)
 * Ok done a bit of testing, pretty much figured out that no matter what I call 
   on the page before the header is included this is ignored other than the template
   call..is this correct?
 *  Thread Starter [rob0210](https://wordpress.org/support/users/rob0210/)
 * (@rob0210)
 * [18 years, 2 months ago](https://wordpress.org/support/topic/header-includes/#post-724066)
 * Last chance at getting an answer to this…. I realise the forums are crammed with
   2.5 disasters but any help with this would be great.
 *  [Clicknathan](https://wordpress.org/support/users/clicknathan/)
 * (@clicknathan)
 * [18 years, 2 months ago](https://wordpress.org/support/topic/header-includes/#post-724067)
 * Hi Rob,
 * Not that it’s going to be much “help”, but I can confirm that you can’t add that
   type of information before the header call. I’ve tried it every which way over
   and over again, it seems that WordPress kills those variables you’re writing.
 * An idea that I had was to call whatever variable is used to determine a Page 
   Template, however I never got any takers on [my support request](http://wordpress.org/support/topic/118054?replies=1).
 * I’m not the master of PHP, though, but perhaps you might have the ability to 
   look into this.
 *  Thread Starter [rob0210](https://wordpress.org/support/users/rob0210/)
 * (@rob0210)
 * [18 years, 2 months ago](https://wordpress.org/support/topic/header-includes/#post-724142)
 * Thanks clicknathan, it did occur to me that it must be WP doing something as 
   my code all seems fine!
 * The only thing I can think to do now is use the is_template tag and call the 
   style and images that way, still don’t know whether it will work though and think
   this conditional tag is only available in 2.5? May be wrong
 *  [Clicknathan](https://wordpress.org/support/users/clicknathan/)
 * (@clicknathan)
 * [18 years, 1 month ago](https://wordpress.org/support/topic/header-includes/#post-724185)
 * Did you have any luck with is_template, Rob?
 *  Thread Starter [rob0210](https://wordpress.org/support/users/rob0210/)
 * (@rob0210)
 * [18 years, 1 month ago](https://wordpress.org/support/topic/header-includes/#post-724200)
 * To be honest I scratched the idea and made seperate images on each template page
   🙁 My reasons are as follows:
 * 1) The website I need it for is currently on 2.3.3 and I am not really prepared
   to upgrade yet until 2.5 has more of its bugs ironed out.
 * 2) I have never really experimented with is_page_template and I dont want to 
   upgrade to 2.5 just to test to see it works.
 * 3) I have a deadline of Thursday for this project so experimental time is nill!
 * I will keep this thread open and If I figure anything out I will post it up.
 * Meanwhile, anyone who knows what is_page_template is capable of and if it can
   be used in wp header or not, would be much appreciated if some light could be
   shed! Thanks
 *  [dave_t](https://wordpress.org/support/users/dave_t/)
 * (@dave_t)
 * [18 years, 1 month ago](https://wordpress.org/support/topic/header-includes/#post-724293)
 * hey guys, check the thread you have going [here](http://wordpress.org/support/topic/118054),
   mfields has posted a (possible) solution… I’m doing something similar with is_page_template.
   if you do wanna use is_page_template(), make sure you pass it the template filename,
   not the name you assign it within that file. eg use `is_page_template('page-about.
   php')` not `is_page_template('about')`. The is_page_template() function lives
   in ‘wp-includes/post-template.php’ in your WP2.5 install. If you wanna test how
   this works, put the following in your sidebar: `<php
    /* test page template */
   if (is_page_template(‘page-home.php’)) { echo (‘<h2>Home template</h2>’); } else{
   $custom_fields = get_post_custom_values(‘_wp_page_template’,$post->ID); $page_template
   = $custom_fields[0]; echo (‘<h2>’ .$page_template. ‘</h2>’); } ?>` (i grabbed
   the second half of this directly from the post-template.php include, so if you’re
   running WP2.3, maybe see if you can manually retrieve the current page template
   using the ‘_wp_page_template’ call as above? )

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

The topic ‘Header Includes’ is closed to new replies.

## Tags

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

 * In: [Fixing WordPress](https://wordpress.org/support/forum/how-to-and-troubleshooting/)
 * 8 replies
 * 3 participants
 * Last reply from: [dave_t](https://wordpress.org/support/users/dave_t/)
 * Last activity: [18 years, 1 month ago](https://wordpress.org/support/topic/header-includes/#post-724293)
 * Status: not resolved

## Topics

### Topics with no replies

### Non-support topics

### Resolved topics

### Unresolved topics

### All topics
