Title: get_header
Published: April 25, 2014
Last modified: February 24, 2026

---

# get_header( string|null $name = null, array $args = array() ): void|false

## In this article

 * [Description](https://developer.wordpress.org/reference/functions/get_header/?output_format=md#description)
 * [Parameters](https://developer.wordpress.org/reference/functions/get_header/?output_format=md#parameters)
 * [Return](https://developer.wordpress.org/reference/functions/get_header/?output_format=md#return)
 * [More Information](https://developer.wordpress.org/reference/functions/get_header/?output_format=md#more-information)
 * [Source](https://developer.wordpress.org/reference/functions/get_header/?output_format=md#source)
 * [Hooks](https://developer.wordpress.org/reference/functions/get_header/?output_format=md#hooks)
 * [Related](https://developer.wordpress.org/reference/functions/get_header/?output_format=md#related)
 * [Changelog](https://developer.wordpress.org/reference/functions/get_header/?output_format=md#changelog)
 * [User Contributed Notes](https://developer.wordpress.org/reference/functions/get_header/?output_format=md#user-contributed-notes)

[ Back to top](https://developer.wordpress.org/reference/functions/get_header/?output_format=md#wp--skip-link--target)

Loads header template.

## 󠀁[Description](https://developer.wordpress.org/reference/functions/get_header/?output_format=md#description)󠁿

Includes the header template for a theme or if a name is specified then a specialized
header will be included.

For the parameter, if the file is called “header-special.php” then specify “special”.

## 󠀁[Parameters](https://developer.wordpress.org/reference/functions/get_header/?output_format=md#parameters)󠁿

 `$name`string|nulloptional

The name of the specialized header.

Default:`null`

`$args`arrayoptional

Additional arguments passed to the header template.

Default:`array()`

## 󠀁[Return](https://developer.wordpress.org/reference/functions/get_header/?output_format=md#return)󠁿

 void|false Void on success, false if the template does not exist.

## 󠀁[More Information](https://developer.wordpress.org/reference/functions/get_header/?output_format=md#more-information)󠁿

If the theme contains no header.php file then the header from the default theme `
wp-includes/theme-compat/header.php` will be included.

## 󠀁[Source](https://developer.wordpress.org/reference/functions/get_header/?output_format=md#source)󠁿

    ```php
    function get_header( $name = null, $args = array() ) {
    	/**
    	 * Fires before the header template file is loaded.
    	 *
    	 * @since 2.1.0
    	 * @since 2.8.0 The `$name` parameter was added.
    	 * @since 5.5.0 The `$args` parameter was added.
    	 *
    	 * @param string|null $name Name of the specific header file to use. Null for the default header.
    	 * @param array       $args Additional arguments passed to the header template.
    	 */
    	do_action( 'get_header', $name, $args );

    	$templates = array();
    	$name      = (string) $name;
    	if ( '' !== $name ) {
    		$templates[] = "header-{$name}.php";
    	}

    	$templates[] = 'header.php';

    	if ( ! locate_template( $templates, true, true, $args ) ) {
    		return false;
    	}
    }
    ```

[View all references](https://developer.wordpress.org/reference/files/wp-includes/general-template.php/)
[View on Trac](https://core.trac.wordpress.org/browser/tags/6.9.4/src/wp-includes/general-template.php#L27)
[View on GitHub](https://github.com/WordPress/wordpress-develop/blob/6.9.4/src/wp-includes/general-template.php#L27-L51)

## 󠀁[Hooks](https://developer.wordpress.org/reference/functions/get_header/?output_format=md#hooks)󠁿

 [do_action( ‘get_header’, string|null $name, array $args )](https://developer.wordpress.org/reference/hooks/get_header/)

Fires before the header template file is loaded.

## 󠀁[Related](https://developer.wordpress.org/reference/functions/get_header/?output_format=md#related)󠁿

| Uses | Description | 
| [locate_template()](https://developer.wordpress.org/reference/functions/locate_template/)`wp-includes/template.php` |

Retrieves the name of the highest priority template file that exists.

  | 
| [do_action()](https://developer.wordpress.org/reference/functions/do_action/)`wp-includes/plugin.php` |

Calls the callback functions that have been added to an action hook.

  |

## 󠀁[Changelog](https://developer.wordpress.org/reference/functions/get_header/?output_format=md#changelog)󠁿

| Version | Description | 
| [5.5.0](https://developer.wordpress.org/reference/since/5.5.0/) | The `$args` parameter was added. | 
| [1.5.0](https://developer.wordpress.org/reference/since/1.5.0/) | Introduced. |

## 󠀁[User Contributed Notes](https://developer.wordpress.org/reference/functions/get_header/?output_format=md#user-contributed-notes)󠁿

 1.   [Skip to note 6 content](https://developer.wordpress.org/reference/functions/get_header/?output_format=md#comment-content-462)
 2.    [Codex](https://profiles.wordpress.org/codex/)  [  11 years ago  ](https://developer.wordpress.org/reference/functions/get_header/#comment-462)
 3.  [You must log in to vote on the helpfulness of this note](https://login.wordpress.org?redirect_to=https%3A%2F%2Fdeveloper.wordpress.org%2Freference%2Ffunctions%2Fget_header%2F%23comment-462)
     Vote results for this note: 13[You must log in to vote on the helpfulness of this note](https://login.wordpress.org?redirect_to=https%3A%2F%2Fdeveloper.wordpress.org%2Freference%2Ffunctions%2Fget_header%2F%23comment-462)
 4.  **Multiple Headers**
      Different header for different pages.
 5.      ```php
         <?php
         if ( is_home() ) :
         	get_header( 'home' );
         elseif ( is_404() ) :
         	get_header( '404' );
         else :
         	get_header();
         endif;
         ?>
         ```
     
 6.  The file names for the home and 404 headers should be `header-home.php` and `header-
     404.php` respectively.
 7.   [Log in to add feedback](https://login.wordpress.org/?redirect_to=https%3A%2F%2Fdeveloper.wordpress.org%2Freference%2Ffunctions%2Fget_header%2F%3Freplytocom%3D462%23feedback-editor-462)
 8.   [Skip to note 7 content](https://developer.wordpress.org/reference/functions/get_header/?output_format=md#comment-content-4901)
 9.    [Ruhul Amin](https://profiles.wordpress.org/amihabibkhan/)  [  5 years ago  ](https://developer.wordpress.org/reference/functions/get_header/#comment-4901)
 10. [You must log in to vote on the helpfulness of this note](https://login.wordpress.org?redirect_to=https%3A%2F%2Fdeveloper.wordpress.org%2Freference%2Ffunctions%2Fget_header%2F%23comment-4901)
     Vote results for this note: 8[You must log in to vote on the helpfulness of this note](https://login.wordpress.org?redirect_to=https%3A%2F%2Fdeveloper.wordpress.org%2Freference%2Ffunctions%2Fget_header%2F%23comment-4901)
 11. **As second parameter in [get_header()](https://developer.wordpress.org/reference/functions/get_header/)
     we can pass an array**
 12.     ```php
         <?php
         // in index.php or where you want to include header
         get_header( '', array( 'name' => 'Ruhul Amin', 'age' => 23 ) ); 
         ?>
         ```
     
 13. We will be able to use this in `header.php`
 14.     ```php
         <h2>This is a Header</h2>
         <p>Hey, <?php echo $args['name']; ?>, You are <?php echo $args['age']; ?> years old</p>
         ```
     
 15.  [Log in to add feedback](https://login.wordpress.org/?redirect_to=https%3A%2F%2Fdeveloper.wordpress.org%2Freference%2Ffunctions%2Fget_header%2F%3Freplytocom%3D4901%23feedback-editor-4901)
 16.  [Skip to note 8 content](https://developer.wordpress.org/reference/functions/get_header/?output_format=md#comment-content-2865)
 17.   [Barrett Golding](https://profiles.wordpress.org/hearvox/)  [  8 years ago  ](https://developer.wordpress.org/reference/functions/get_header/#comment-2865)
 18. [You must log in to vote on the helpfulness of this note](https://login.wordpress.org?redirect_to=https%3A%2F%2Fdeveloper.wordpress.org%2Freference%2Ffunctions%2Fget_header%2F%23comment-2865)
     Vote results for this note: 2[You must log in to vote on the helpfulness of this note](https://login.wordpress.org?redirect_to=https%3A%2F%2Fdeveloper.wordpress.org%2Freference%2Ffunctions%2Fget_header%2F%23comment-2865)
 19. **Named header template**
      Load an alternate header file by using the `$name` 
     param: `<?php get_header( 'special' ); ?>`
 20. The above code in a theme file will load the template file: `header-special.php`.
     If not found, will default to loading: `header.php`.
 21.  [Log in to add feedback](https://login.wordpress.org/?redirect_to=https%3A%2F%2Fdeveloper.wordpress.org%2Freference%2Ffunctions%2Fget_header%2F%3Freplytocom%3D2865%23feedback-editor-2865)
 22.  [Skip to note 9 content](https://developer.wordpress.org/reference/functions/get_header/?output_format=md#comment-content-5445)
 23.   [Muhammad Jawad Abbasi](https://profiles.wordpress.org/jawad1234/)  [  4 years ago  ](https://developer.wordpress.org/reference/functions/get_header/#comment-5445)
 24. [You must log in to vote on the helpfulness of this note](https://login.wordpress.org?redirect_to=https%3A%2F%2Fdeveloper.wordpress.org%2Freference%2Ffunctions%2Fget_header%2F%23comment-5445)
     Vote results for this note: 1[You must log in to vote on the helpfulness of this note](https://login.wordpress.org?redirect_to=https%3A%2F%2Fdeveloper.wordpress.org%2Freference%2Ffunctions%2Fget_header%2F%23comment-5445)
 25. **Pass array as second parameter in [get_header()](https://developer.wordpress.org/reference/functions/get_header/)**
 26.     ```php
         <?php
         // that code put in page.php, single.php etc
         // I have put that code in index.php file
         get_header( '', array( 'menu' => wp_nav_menu( array(
         	'menu' => 'wpdocs_primary_menu',
         	'menu_class' => 'wpdocs_header_menu',
         	'menu_id' => 'wpdocs_nav_menu',
         ) ) ) );
         ?>
         ```
     
 27. **Put a code on header.php**
 28.     ```php
         <?php echo $args['menu']; ?>
         ```
     
 29. **Output:**
      Show menu item that setup in the WordPress dashboard
 30. **Note:**
      In the above code class `wpdocs_header_menu` assign to the menu and
     also id `wpdocs_nav_menu` assign to the menu. So you can style the menu according
     to the requirements.
 31.  [Log in to add feedback](https://login.wordpress.org/?redirect_to=https%3A%2F%2Fdeveloper.wordpress.org%2Freference%2Ffunctions%2Fget_header%2F%3Freplytocom%3D5445%23feedback-editor-5445)
 32.  [Skip to note 10 content](https://developer.wordpress.org/reference/functions/get_header/?output_format=md#comment-content-461)
 33.   [Codex](https://profiles.wordpress.org/codex/)  [  11 years ago  ](https://developer.wordpress.org/reference/functions/get_header/#comment-461)
 34. [You must log in to vote on the helpfulness of this note](https://login.wordpress.org?redirect_to=https%3A%2F%2Fdeveloper.wordpress.org%2Freference%2Ffunctions%2Fget_header%2F%23comment-461)
     Vote results for this note: -12[You must log in to vote on the helpfulness of this note](https://login.wordpress.org?redirect_to=https%3A%2F%2Fdeveloper.wordpress.org%2Freference%2Ffunctions%2Fget_header%2F%23comment-461)
 35. **Simple 404 page**
      The following code is a simple example of a template for 
     an “HTTP 404: Not Found” error (which you could include in your theme as `404.
     php`).
 36.     ```php
         <?php get_header(); ?>
     
         <h2><?php esc_html_e( 'Error 404 - Not Found', 'textdomain' ); ?></h2>
     
         <?php get_sidebar(); ?>
         <?php get_footer(); ?>
         ```
     
 37.  [Log in to add feedback](https://login.wordpress.org/?redirect_to=https%3A%2F%2Fdeveloper.wordpress.org%2Freference%2Ffunctions%2Fget_header%2F%3Freplytocom%3D461%23feedback-editor-461)

You must [log in](https://login.wordpress.org/?redirect_to=https%3A%2F%2Fdeveloper.wordpress.org%2Freference%2Ffunctions%2Fget_header%2F)
before being able to contribute a note or feedback.