WordPress函数介绍——获取页脚函数get_footer详解。

该函数位于wp-include/general-template.php 文件的第 61 行左右的位置,代码如下。
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|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 );}PHP函数需要使用<?php ?>包裹,调用方法为:
<?php get_footer();?>
由上面的函数原型可以看出,get_footer函数需要一个字符串类型参数,并且该参数允许为空,为空时查找主题目录下footer.php文件,不存在则使用默认的 wp-includes/theme-compat/footer.php 作为页脚,不为空时查找footer-参数名.php文件作为头部。
如传入dAImadog
<?php get_footer('daimadog');?>此时将加载主题目录下的footer-daimadog.php作为网站的头部文件。
安装KB5014697补丁以后开启热点无法上网怎么办?
Windows 11 的最新星期二补丁KB5014697更...(627 )人阅读时间:2025-11-25
Win11本地安全策略在哪里?Win11添加IP 安全策略的
IP安全策略是一个给予通讯分析的策略,当我们配置好IP安全...(948 )人阅读时间:2025-11-25
Win11字体显示不全如何解决?Win11字体显示不全解决方
Win11系统是当前最好用的系统之一,在给用户带来全新界面...(752 )人阅读时间:2025-11-25
Win11怎么创建虚拟磁盘?Win11创建虚拟磁盘的方法
虚拟磁盘就是用内存中虚拟出一个或者多个磁盘的技术。和虚拟内...(607 )人阅读时间:2025-11-25