Title: get_header doesn&#8217;t work but include(TEMPLATEPATH.&#8217;/header.php&#8217;) does
Last modified: August 19, 2016

---

# get_header doesn’t work but include(TEMPLATEPATH.’/header.php’) does

 *  [triplex2k7](https://wordpress.org/support/users/triplex2k7/)
 * (@triplex2k7)
 * [18 years, 4 months ago](https://wordpress.org/support/topic/get_header-doesnt-work-but-includetemplatepathheaderphp-does/)
 * Hi,
    I am building a theme loosely following the structure of WordPress default
   theme. I completed index.php and started to split it up into different files.
   I cut and pasted everything in the page up to the ‘content’ div into a new file,
   and saved this as ‘header.php’ in the same directory as index.php. I used the
   code `<?php get_header(); ?>` to include it. However, this broke some of the 
   php code, such as `get_category_rss_link` and `get_permalink`, which worked before.
   I tried changing get_header to `<?php include(TEMPLATEPATH.'/header.php'); ?>`
   and it worked. Have I made a mistake or does certain code break when using get_header?
   Also, do I need to use get_header for certain functions or will include() suffice?

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

 *  Thread Starter [triplex2k7](https://wordpress.org/support/users/triplex2k7/)
 * (@triplex2k7)
 * [18 years, 4 months ago](https://wordpress.org/support/topic/get_header-doesnt-work-but-includetemplatepathheaderphp-does/#post-695115)
 * Ok, this is to do with my last question about whether get_header is required 
   for the theme to work.
    I’ve looked in wp-includes/general-template.php where
   function get_header is defined and it does the following things:
    1. `do_action( 'get_header' );`
    2. Checks if there is a header.php template file.
    3. If there is, it includes it
    4. If there isn’t, it includes one from the default theme
 * As far as I know, do_action is used to create hooks for plugins to use. So, should
   I just add the code `do_action( 'get_header' );` above my `include(TEMPLATEPATH.'/
   header.php')`?
 *  Moderator [Samuel Wood (Otto)](https://wordpress.org/support/users/otto42/)
 * (@otto42)
 * WordPress.org Admin
 * [18 years, 4 months ago](https://wordpress.org/support/topic/get_header-doesnt-work-but-includetemplatepathheaderphp-does/#post-695122)
 * No, you should use the get_header() function instead of reinventing the wheel.
   The get_header() function is expected and should always be used. Same as with
   get_sidebar() and get_footer(). Just because that is what it does now does not
   mean that that is not subject to change in the future, and so you need to do 
   the right thing in your theme to be forward-compatible.
 * If this causes you problems, then you need to explain those problems in more 
   detail, so that we can help you solve them. Use of get_header() should not change
   the get_permalink or get_category_rss_link functions, as those are not Loop functions
   and they use their own globals.
 * However, use of get_header will remove access to global vars from the header.
   php file. This is intentional, if you want to use globals in header.php, you 
   have to declare them as such.
 *  Thread Starter [triplex2k7](https://wordpress.org/support/users/triplex2k7/)
 * (@triplex2k7)
 * [18 years, 3 months ago](https://wordpress.org/support/topic/get_header-doesnt-work-but-includetemplatepathheaderphp-does/#post-695322)
 * Ok thanks. I think the problem is with global variables rather than the functions.
 *  Thread Starter [triplex2k7](https://wordpress.org/support/users/triplex2k7/)
 * (@triplex2k7)
 * [18 years, 3 months ago](https://wordpress.org/support/topic/get_header-doesnt-work-but-includetemplatepathheaderphp-does/#post-695327)
 * Thank you, that has solved it.
 * The problem was that I was defining variables containing page and category IDs
   in `functions.php` (Is this bad practise? Is there a better place to put them?)
   and I did not know that you could not use global variables in `header.php`.
 * To solve this I added the code `<?php global $myvar1, $myvar2, $myvar3; ?>`.
 * This works, but I am worried that I may still be going about this the wrong way.

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

The topic ‘get_header doesn’t work but include(TEMPLATEPATH.’/header.php’) does’
is closed to new replies.

## Tags

 * [breaks](https://wordpress.org/support/topic-tag/breaks/)
 * [code](https://wordpress.org/support/topic-tag/code/)
 * [get_header](https://wordpress.org/support/topic-tag/get_header/)

 * 4 replies
 * 2 participants
 * Last reply from: [triplex2k7](https://wordpress.org/support/users/triplex2k7/)
 * Last activity: [18 years, 3 months ago](https://wordpress.org/support/topic/get_header-doesnt-work-but-includetemplatepathheaderphp-does/#post-695327)
 * Status: not resolved

## Topics

### Topics with no replies

### Non-support topics

### Resolved topics

### Unresolved topics

### All topics
