欢迎来到站长天空!

WordPress

当前位置: 主页 > CMS教程 > WordPress

WordPress获取页脚函数get_footer用法

时间:2025-10-19 15:11:12|栏目:WordPress|点击:

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

WordPress教程

函数原型

该函数位于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作为网站的头部文件。


上一篇:WordPress获取评论模板函数comments_template用法

栏    目:WordPress

下一篇:WordPress获取头部函数get_header用法

本文标题:WordPress获取页脚函数get_footer用法

本文地址:https://zz.feitang.co/CMSjiaocheng/25145.html

广告投放 | 联系我们 | 版权申明

申明:本站所有的文章、图片、评论等,均由网友发表或上传并维护或收集自网络,属个人行为,与本站立场无关。

如果侵犯了您的权利,请与我们联系,我们将在24小时内进行处理、任何非本站因素导致的法律后果,本站均不负任何责任。

联系QQ:257218569 | 邮箱:257218569@qq.com

Copyright © 2018-2025 站长天空 版权所有 Powered by EyouCms冀ICP备14023439号