WordPress获取页脚函数get_footer用法
发布时间:2025-10-19 15:10:24 本站作者 【 字体:大 中 小 】 浏览:100 次
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作为网站的头部文件。
热门推荐
最新发布
酱骨架的家常做法
材料骨架,盐,老抽,白酒做法1.骨架用盐和少许老抽,白酒腌制.不加水2.把腌制好的骨架扔进高压锅,中火,上气后调小火五分钟,关火,焖一会儿再打开锅盖3.接下来要做的就是啃了,喜欢喝酒可以一边喝酒一边啃,很爽吧...
咕噜肉最正宗的做法
咕噜肉又称甜酸肉或咕咾肉,是广东的一道汉族传统名菜,属于粤菜,以甜酸汁及猪肉煮成。这道菜是欧美人士最熟悉的中国菜之一,因此广见于中国以外的唐人街的餐馆。咕噜肉的主料去皮五花猪肉500克,熟鲜笋肉150克,鸡蛋液30克,辣椒25克,葱段5克,蒜泥,芝麻油各5克,精盐1.5克,汾酒7.5克,湿淀粉40克,干淀粉...
东坡肉最正宗的做法
东坡肉(滚肉、红烧肉)是杭州名菜,用猪肉炖制而成。其色、香、味俱佳,深受人们喜爱。慢火,少水,多酒,是制作这道菜的诀窍。一般是一块约二寸许的方正形猪肉,一半为肥肉,一半为瘦肉,入口香糯、肥而不腻,带有酒香,色泽红亮,味醇汁浓,酥烂而形不碎,十分美味。东坡肉的材料猪五花肋肉1000克,葱100克,冰糖...
木须肉最正宗的做法
一点鸡蛋,一点黄瓜,少许肉片,就能做出我很喜欢吃的木须肉了。木须肉的材料猪肉150克,鸡蛋2个,黄瓜50克,木耳5克,葱花、姜末、盐、料酒、香油、味精、淀粉各适量木须肉的做法1.将鸡蛋打入碗中,先取少量蛋清放入一个干净的碗中,再用筷子将剩下的鸡蛋搅打均匀。2.猪肉洗净切成薄片,用刚才预留的...






