get_header WordPress Action Hook

The get_header Wordpress hook is one of the most important hooks in Wordpress. It is used to load the header template for a Wordpress theme. This hook is typically used by themes to add extra code or data to the header before it is rendered.

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

Fires before the header template file is loaded.


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.


Top ↑

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.


Top ↑

Source

File: wp-includes/general-template.php

View on Trac



Top ↑

Changelog

Changelog
VersionDescription
5.5.0The $args parameter was added.
2.8.0The $name parameter was added.
2.1.0Introduced.

The content displayed on this page has been created in part by processing WordPress source code files which are made available under the GPLv2 (or a later version) license by the Free Software Foundation. In addition to this, the content includes user-written examples and information. All material is subject to review and curation by the WPPaste.com community.

Show More
Show More