Using WordPress ‘get_header()’ PHP function

The get_header() WordPress PHP function loads the header template for a theme, or a specialized header if a name is specified.


get_header(); // Loads the default header template

get_header(‘special’); // Loads the specialized header template named “header-special.php”


  • $name (string) (Optional): The name of the specialized header. Default: null
  • $args (array) (Optional): Additional arguments passed to the header template. Default: array()

More information

See WordPress Developer Resources: get_header()


Load Default Header

Load the default header template file (header.php) in your theme:


Load Specialized Header

Load a specialized header template file, such as header-special.php:


Load Header with Additional Arguments

Load the default header template, but pass additional arguments to the template:

get_header('', array('custom_key' => 'custom_value'));

Pass Multiple Arguments to Header Template

Load the default header template and pass multiple arguments to the template:

get_header('', array('key1' => 'value1', 'key2' => 'value2'));

Use Additional Arguments in Header Template

First, pass the arguments to the header template:

get_header('', array('title' => 'My Custom Title'));

Then, access the passed arguments in your header.php file:

// In header.php
$title = $args['title'] ?? 'Default Title';
echo '<h1>' . esc_html($title) . '</h1>';