详解WordPress开发中get_header()获取头部函数的用法


本文整理自网络,侵删。

函数意义详解
从当前主题调用header.php文件。是不是很简单?好吧,如果你是新手的话这里要提醒一下,这里的get和get_children()、get_category中的get略有不同之处。

get_header函数声明(定义)
之前写文章很少会写到函数定义的代码,后来自己翻看的时候发现这个习惯不太好,所以决定,只要篇幅允许,就会把函数主题贴出来,方便自己翻看。
get_header 函数,声明(定义)的位置,是在 wp=include/general-template.php 文件的第 24 – 36 行左右的位置。

function get_header( $name = null ) {
 do_action( 'get_header', $name );
 
 $templates = array();
 if ( isset($name) )
 $templates[] = "header-{$name}.php";
 
 $templates[] = 'header.php';
 
 // Backward compat code will be removed in a future release
 if ('' == locate_template($templates, true))
 load_template( ABSPATH . WPINC . '/theme-compat/header.php');
}

get_header函数的使用

<?php get_header( $name ); ?>

很简单,从上面的函数声明中我们也能看出,该函数只接受一个变量作为参数。

阅读剩余部分

相关阅读 >>

nginx服务器下使用rewrite重写url以实现伪静态的示例

nginx服务lnmp之wordpress部署流程步骤

wordpress更换主题模板 究竟会不会影响网站seo

更改wordpress自动生成摘要的方式

详解wordpress中给链接添加查询字符串的方法

完美实现wordpress禁止文章修订和自动保存的方法

wordpress固定链接伪静态的设置方法

wordpress忘记后台密码怎么办 轻松找回wp密码的方法

wordpress修改某篇文章id(把id为148的改成147)的sql语句

wordpress之多备份插件使用方法

更多相关阅读请进入《wordpress》频道 >>



打赏

取消

感谢您的支持,我会继续努力的!

扫码支持
扫码打赏,您说多少就多少

打开支付宝扫一扫,即可进行扫码打赏哦

分享从这里开始,精彩与您同在

评论

管理员已关闭评论功能...