功能:加载页脚模板。
get_footer(string $ name = null )
描述
包含主题的页脚模板,或者如果指定了名称,则将包含专用页脚。
对于参数,如果文件名为“footer-special.php”,则指定参数为“special”。
参数
$名称
(string) (可选) 专用页脚的名称。
默认值:null
来源
function get_footer( $name = null ) {
/**
* Fires before the footer template file is loaded.
*
* @since 2.1.0
* @since 2.8.0 $name parameter added.
*
* @param string|null $name Name of the specific footer file to use. null for the default footer.
*/
do_action( 'get_footer', $name );
$templates = array();
$name = (string) $name;
if ( '' !== $name ) {
$templates[] = "footer-{$name}.php";
}
$templates[] = 'footer.php';
locate_template( $templates, true );
}
相关
用途描述wp-includes / general-template.php: get_footer在加载页脚模板文件之前触发。
wp-includes / plugin.php: do_action()执行挂钩在特定操作挂钩上的函数。
wp-includes / template.php: locate_template()检索存在的最高优先级模板文件的名称。
使用示例
多页脚
不同页面的不同页脚。
elseif ( is_404() ) :get_footer( '404' );
else :get_footer();endif;?>
home和404页脚的文件名应分别为footer-home.php和footer-404.php。
命名页脚模板
使用$name参数加载备用页脚文件:
主题文件中的上述代码将加载模板文件:footer-special.php。如果没有找到,将默认加载:footer.php。
简单404页面
以下代码是“HTTP 404:Not Found”错误的模板的简单示例(您可以在主题中包含该错误404.php)。