站长资源
中国站长网站

WordPress模板包含标签:get_footer()详解

描述

引入当前主题的页脚文件 footer.php,如果使用特定的名字,那么就会调用这个特定名字的页脚文件 footer-{name}.php 。

如果主题没有 footer.php 就会引入默认的 wp-includes/theme-compat/footer.php 。

用法

<?php get_footer( $name ); ?>

参数

$name
(string) (可选) 调用 footer-name.php.
默认: None
例子

404页面

下面的代码是一个简单的404页面模板 “HTTP 404: Not Found” (它应该包含在你的主题中,名为  404.php)

<?php get_header(); ?>
<h2>Error 404 - Not Found</h2>
<?php get_sidebar(); ?>
<?php get_footer(); ?>

多个页脚

不同的页面显示不同的页脚

<?php
if ( is_home() ) :
	get_footer( 'home' );
elseif ( is_404() ) :
	get_footer( '404' );
else :
	get_footer();
endif;
?>

首页和404页面的专用页脚应该分别命名为 footer-home.php 和 footer-404.php 。

资源文件

get_footer() 包含在 wp-includes/general-template.php.

相关函数

get_header(),  get_sidebar(), get_template_part(), get_search_form(),comments_template()

本文出处:来自互联网信息共享,请勿相信收费信息站长资源 » WordPress模板包含标签:get_footer()详解

评论 抢沙发

评论前必须登录!