Example 1 — Load the default header
Start a template with the header.
<?php get_header(); ?>
<main>Post content</main>
<?php get_footer(); ?> How It Works
get_header()loadsheader.php.- Your post content follows.
get_footer()closes the page.

In WordPress, get_header() loads the theme header file. By default it loads header.php.
If you pass a name, such as get_header( 'shop' ), WordPress looks for header-shop.php first. If that file does not exist, it falls back to header.php.
Call it at the top of a template file.
<?php
get_header();
// or a named header:
get_header( 'shop' ); | Call | What it does |
|---|---|
get_header() | Loads header.php. |
get_header( 'shop' ) | Loads header-shop.php, then header.php if it is missing. |
get_header( null, $args ) | Loads header.php and passes data to it. |
Remember to call wp_head() inside header.php.
get_header( string|null $name = null, array $args = [] ): void|false | Parameter | Description |
|---|---|
$name | string|null. The name of a special header. Default is null. |
$args | array. Extra data for the header file. It is available as $args inside it. Default is an empty array. |
| Return Value | Description |
|---|---|
| void|false | The header is loaded. It returns false if no header file was found. |
Three short theme examples. Each one shows the code and what it prints.
Start a template with the header.
<?php get_header(); ?>
<main>Post content</main>
<?php get_footer(); ?> get_header() loads header.php.get_footer() closes the page.Use header-home.php on the front page.
<?php get_header( 'home' ); ?> header- and .php.header-home.php first.header.php is used.Pick the name with a conditional tag.
<?php
if ( is_page( 'contact' ) ) {
get_header( 'contact' );
} else {
get_header();
} is_page( 'contact' ) checks the page slug.Print or return the site search form.
8 people found this page helpful