The What
It’s been available for you since version 1.5.0.
Description
This construct fires the event get_header
and then locates the template to be loaded. If a specific template name was supplied when calling this function, it will search for header-{$specific_template_name}.php
; else it searches for header.php
. If the template is found, then it’s loaded; otherwise, WordPress loads the default theme template is loaded from wp-includes/theme-compat/header.php
.
Parameters
specific_template_name
- optional The name of the specific header you want to find and load. Remember not to include “header-“; rather, it’s just the partial name of the PHP file.
Return Values
This function does not return anything.
Break. Go rest your noodle for a couple of minutes.
Real World ExamplesBasic
Let’s look at three different themes in order to see how to use get_header
. You will see it in action including the rendered HTML in the browser.
Go Deep into CorePro
In these two videos, you will go into WordPress Core to see how it works as well as reverse engineer it. You’ll see the event get_header
as you register a callback to it. You’ll learn about type casting. You’ll build dummy templates and then see how Core looks for the template file in the child theme first and then the parent theme.
Also to help you further in understanding type casting, memory, symbols table, and more, there is a lab called PHP Variables Bootcamp.