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

---

# do_action( ‘get_header’, string|null $name, array $args )

## In this article

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

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

Fires before the header template file is loaded.

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

 `$name`string|null

Name of the specific header file to use. Null for the default header.

`$args`array

Additional arguments passed to the header template.

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

`get_header` is a hook that gets run at the very start of the `get_header` function
call. If you pass in the name for a specific header file into the function `get_header()`,
like `get_header( 'new' )`, the `do_action` will pass in the same name as a parameter
for the hook. This allows you to limit your `add_action` calls to specific templates
if you wish. Actions added to this hook should be added to your functions.php file.

Note: This hook is best to use to set up and execute code that doesn’t get echoed
to the browser until later in the page load. Anything you echo will show up before
any of the markups is displayed.

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

    ```php
    do_action( 'get_header', $name, $args );
    ```

[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#L38)
[View on GitHub](https://github.com/WordPress/wordpress-develop/blob/6.9.4/src/wp-includes/general-template.php#L38-L38)

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

| Used by | Description | 
| [get_header()](https://developer.wordpress.org/reference/functions/get_header/)`wp-includes/general-template.php` |

Loads header template.

  |

## 󠀁[Changelog](https://developer.wordpress.org/reference/hooks/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. | 
| [2.8.0](https://developer.wordpress.org/reference/since/2.8.0/) | The `$name` parameter was added. | 
| [2.1.0](https://developer.wordpress.org/reference/since/2.1.0/) | Introduced. |

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

 1.  [Skip to note 2 content](https://developer.wordpress.org/reference/hooks/get_header/?output_format=md#comment-content-4279)
 2.   [Collins Mbaka](https://profiles.wordpress.org/collinsmbaka/)  [  6 years ago  ](https://developer.wordpress.org/reference/hooks/get_header/#comment-4279)
 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%2Fhooks%2Fget_header%2F%23comment-4279)
    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%2Fhooks%2Fget_header%2F%23comment-4279)
 4. The following example will enqueue stylesheets conditionally for different headers.
    This is just one example of how you may use the hook and will use a secondary template
    file of `header-new.php`
 5.     ```php
        function wpdocs_themeslug_header_hook( $name ) {
        	if ( 'new' == $name ) {
        		add_action( 'wp_enqueue_scripts', 'wpdocs_themeslug_header_style' );
        	}
        }
        add_action( 'get_header', 'wpdocs_themeslug_header_hook' );
    
        function wpdocs_themeslug_header_style() {
        	wp_enqueue_style( 'wpdocs-header-new-style', get_template_directory_uri() . '/css/header-new.css' );
        }
        ```
    
 6.  [Log in to add feedback](https://login.wordpress.org/?redirect_to=https%3A%2F%2Fdeveloper.wordpress.org%2Freference%2Fhooks%2Fget_header%2F%3Freplytocom%3D4279%23feedback-editor-4279)

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