详解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 ); ?>

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

阅读剩余部分

相关阅读 >>

wordpress配置文件wp-config.php详解

wordpress给文章图片自动添加链接的方法

wordpress网站迁移到新主机防火墙配置

通过自定义字段重新排序 wordpress 文章方法

wordpress 照片lightbox效果的运用几点

利用fix rss feeds插件修复wordpress的feed显示错误

几个优化wordpress中javascript加载体验的插件介绍

nginx环境下wordpress的多站点功能配置详解

wordpress使用rss feed输出自定义文章类型内容的方法

在centos系统上从零开始搭建wordpress博客的全流程记录

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



打赏

取消

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

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

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

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

评论

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