Get_header () (Get head)
introduces the header template of the theme, which by default introduces the header.php file in the current topic directory. If a name is specified, the header-{name}.php file for the current topic directory is introduced, and the wp-includes/theme-compat/header.php file is introduced if the file you want to introduce does not exist.
Usage
Parameters
$name
(optionally) the name of the file to be introduced and, if specified, the header-{$name}.php file.
Example
The code above will introduce the header.php file in the root of the current topic.
<?php get_header (' main ');?>
The code above will introduce the header-main.php file in the root of the current topic.
if (Is_home ()) Get_header (' home ');
ElseIf (is_404 ()) get_header (' 404 ');
else Get_header ();
The above code introduces the header-home.php file of the current topic root in the first page, 404 pages introduces the header-404.php file of the current topic root, and the other pages introduce the header.php file of the current topic root directory.
Other
This function is located at: wp-includes/general-template.php
Get_footer () (Get bottom)
Get_footer () is used to introduce the bottom template file. If the specified name introduces the footer-{name}.php file of the current topic root, if not specified, the footer.php file is introduced into the current topic root, and if the file does not exist, the wp-includes/theme-compat/ footer.php files.
Usage
Parameters
$name
(optionally) introduce the name of the template and, if specified, introduce the footer-{$name}.php file.
return value
There is no return value for this function.
Example
Introduce the footer.php file for the current topic root:
Introduce the footer-new.php file for the current topic root:
<?php get_footer (' new ');?>
Introduce different bottom template files based on different pages:
if (is_404 ()) get_footer (' 404 ');//if 404 pages, introduce the footer-404.php file
elseif (Is_home ()) get_footer (' home ') of the current topic root; /If it is the first page, introduce the footer-home.php file of the current topic root.
else Get_footer ();//If not the first or 404 pages, introduce the footer.php file of the current topic root directory
Other
This function is located at: wp-includes/general-template.php