描述:
- 导入footer.php文件。
- 如果设置了参数 $name ,则会导入footer-{name}.php文件。
- 如果主题文件夹中没有footer-{name}.php文件,则导入wordpress默认主题的sidebar.php文件(wp-includes/theme-compat/footer.php)。
用法:
<?php get_footer( $name ); ?>
参数:
$name
(string) (可选) 调用 footer-name.php.
默认值: None
返回值:
None
示例:
<?php get_header(); ?>
<h2>Error 404 - Not Found</h2>
<?php get_sidebar(); ?>
<?php get_footer(); ?>
源文件:
/**
* Load footer template.
*
* Includes the footer template for a theme or if a name is specified then a
* specialised footer will be included.
*
* For the parameter, if the file is called "footer-special.php" then specify
* "special".
*
* @since 1.5.0
*
* @param string $name The name of the specialised footer.
*/
function get_footer( $name = null ) {
/**
* Fires before the footer template file is loaded.
*
* The hook allows a specific footer template file to be used in place of the
* default footer template file. If your file is called footer-new.php,
* you would specify the filename in the hook as get_footer( 'new' ).
*
* @since 2.1.0
* @since 2.8.0 $name parameter added.
*
* @param string $name Name of the specific footer file to use.
*/
do_action( 'get_footer', $name );
$templates = array();
$name = (string) $name;
if ( '' !== $name )
$templates[] = "footer-{$name}.php";
$templates[] = 'footer.php';
// Backward compat code will be removed in a future release
if ('' == locate_template($templates, true))
load_template( ABSPATH . WPINC . '/theme-compat/footer.php');
}