Explanation of function meaning
Invokes the header.php file from the current topic. Isn't it simple? Well, if you're a novice, here's a reminder that get and Get_children () and get_category get slightly different here.
get_header function declaration (definition)
Before writing the article rarely write the code of the function definition, and later found that the habit is not very good, so decided, as long as the space allows, will be the function of the theme paste out, to facilitate their own look.
The position of the Get_header function, declared (defined), is the position around the 24–36 line of the wp=include/general-template.php file.
function Get_header ($name = null) {do_action (' Get_header ', $name); $templates = Array (); if (Isset ($name)) $templates [] = "header-{$name}.php"; $templates [] = ' header.php '; Backward Compat code would be removed in a future release if (' = = = Locate_template ($templates, True)) Load_template (AB spath. Wpinc. '/theme-compat/header.php ');}
Use of the Get_header function
<?php Get_header ($name);?>
Very simply, from the function declaration above we can see that the function only accepts a variable as a parameter.
Parameter interpretation
$name, as we can see from the function declaration above, $name is a string variable used to invoke the alias template of the header.
For example $name = "AB";
That's what we do.
<?php $name = "AB" Get_header ($name); ? >
This will call the header-ab.php file as the header file.
Example:
1. Simple 404 page
The following code is a simple template file, specifically used to display "HTTP 404:not Found" error (this file should be included in your theme, named 404.php)
<?php Get_header ();?>Error 404-not Found
<?php Get_sidebar (); ><?php get_footer ();?>
2. Multiple head
Show different headers for different pages
<?phpif (Is_home ()): Get_header (' home '); ElseIf (is_404 ()): Get_header (' 404 '); Else:get_header (); endif;? >
These headers for home and 404 should be named header-home.php and header-404.php, respectively.
The above describes the introduction of the WordPress development in the use of Get_header function, including the aspects of the content, I hope that the PHP tutorial interested in a friend helpful.