wordpress footer.php,wordpress的get_footer( )函数功能详解

功能:加载页脚模板。

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)。

Error 404 - Not Found

  • 0
    点赞
  • 0
    收藏
    觉得还不错? 一键收藏
  • 0
    评论

“相关推荐”对你有帮助么?

  • 非常没帮助
  • 没帮助
  • 一般
  • 有帮助
  • 非常有帮助
提交
评论
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

当前余额3.43前往充值 >
需支付:10.00
成就一亿技术人!
领取后你会自动成为博主和红包主的粉丝 规则
hope_wisdom
发出的红包
实付
使用余额支付
点击重新获取
扫码支付
钱包余额 0

抵扣说明:

1.余额是钱包充值的虚拟货币,按照1:1的比例进行支付金额的抵扣。
2.余额无法直接购买下载,可以购买VIP、付费专栏及课程。

余额充值