2024年10月17日 建站教程
函数原型:
get_footer( string $name = null, array $args = array() ): void|false
包含主题的页脚模板,或者如果指定了名称,则将包含专用页脚。对于参数 $name,如果文件名为“footer-special.php”,则应指定 $name 为:“special”。
参数说明:
$name,指定 header 模板的名称,如果为空则加载 footer.php。如果 $name=’special’,则加载 footer-specific.php 。
$args,传给 header 模板的参数。
函数源码:
function get_footer( $name = null, $args = array() ) {
do_action( 'get_footer', $name, $args );
$templates = array();
$name = (string) $name;
if ( '' !== $name ) {
$templates[] = "footer-{$name}.php";
}
$templates[] = 'footer.php';
if ( ! locate_template( $templates, true, true, $args ) ) {
return false;
}
}
包含钩子:
do_action( 'get_footer', string|null $name, array $args )
使用举例:
<?php if ( is_home() ) : get_footer( 'home' ); elseif ( is_404() ) : get_footer( '404' ); else : get_footer(); endif; ?>
本文链接:http://so.lmcjl.com/news/15601/