get_header
Action HookDescription
Fires before the header template file is loaded.Hook Information
File Location |
wp-includes/general-template.php
View on GitHub
|
Hook Type | Action |
Line Number | 38 |
Hook Parameters
Type | Name | Description |
---|---|---|
string|null
|
$name
|
Name of the specific header file to use. Null for the default header. |
array
|
$args
|
Additional arguments passed to the header template. |
Usage Examples
Basic Usage
<?php
// Hook into get_header
add_action('get_header', 'my_custom_function', 10, 2);
function my_custom_function($name, $args) {
// Your custom code here
}
Source Code Context
wp-includes/general-template.php:38
- How this hook is used in WordPress core
<?php
33 * @since 5.5.0 The `$args` parameter was added.
34 *
35 * @param string|null $name Name of the specific header file to use. Null for the default header.
36 * @param array $args Additional arguments passed to the header template.
37 */
38 do_action( 'get_header', $name, $args );
39
40 $templates = array();
41 $name = (string) $name;
42 if ( '' !== $name ) {
43 $templates[] = "header-{$name}.php";
PHP Documentation
<?php
/**
* 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.
*/
Quick Info
- Hook Type: Action
- Parameters: 2
- File: wp-includes/general-template.php
Related Hooks
Related hooks will be displayed here in future updates.