Get the header template and the bottom template, and the WordPress header. Get the header template and the bottom template in the WordPress topic writing. the wordpress header get_header () (get the header) introduces the header template of the topic, by default, the header template and the bottom template are obtained from the WordPress topic compiling in the current topic directory. the wordpress header
Get_header () (obtain the header)
Introduce the header template of the topic. by default, the header. php file in the current topic directory is introduced. If a name is specified, the header-{name} of the current topic directory is introduced }. php file. if the file to be introduced does not exist, introduce wp-nodes des/theme-compat/header. php file.
Usage
get_header( $name );
Parameters
$ Name
(String) (optional) name of the file to be introduced. if specified, the header-{$ name}. php file is introduced.
Example
<?php get_header(); ?>
The above code will introduce the header. php file in the root directory of the current topic.
<?php get_header( 'main' ); ?>
The code above introduces the header-main.php file of the current topic root directory.
if( is_home() ) get_header( 'home' );elseif( is_404() ) get_header( '404' );else get_header();
The code above will introduce the header-home.php file for the current topic root directory on the home page, page 404 will introduce the header-404.php file for the current topic root directory, other pages will introduce the header. php file for the current topic root directory.
Others
This function is located in: wp-des/general-template.php
Get_footer () (get the bottom)
Get_footer () is used to introduce the bottom template file. If the name is specified, the footer-{name} of the root directory of the current topic is introduced }. php file. if not specified, the footer of the root directory of the current topic will be introduced. php file. if the file does not exist, introduce wp-nodes des/theme-compat/footer. php file.
Usage
get_footer( $name );
Parameters
$ Name
(String) (optional) name of the imported template. if specified, the footer-{$ name}. php file is introduced.
Return value
This function has no return value.
Example
Introduce the footer. php file in the root directory of the current topic:
<?php get_footer(); ?>
Introduce the footer-new.php file for the current topic root directory:
<?php get_footer( 'new' ); ?>
Introduce different bottom template files based on different pages:
If (is_404 () get_footer ('20140901'); // if the page is 404, introduce the footer-404.php file elseif (is_home () for the root directory of the current topic ()) get_footer ('Home'); // if it is the home page, introduce the footer-home.php file else get_footer () for the root directory of the current topic (); // if it is not the home page or 404 page, the footer of the root directory of the current topic will be introduced. php files
Others
This function is located in: wp-des/general-template.php
Articles you may be interested in:
- Describes the PHP functions used in WordPress to obtain comment templates and search forms.
- How to introduce a template file for WordPress topic creation
Javasget_header () (obtain the header) introduces the header template of the topic. by default, the header template in the current topic directory is introduced...