本文整理自网络,侵删。
函数意义详解
从当前主题调用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以实现伪静态的示例
wordpress忘记后台密码怎么办 轻松找回wp密码的方法
wordpress修改某篇文章id(把id为148的改成147)的sql语句
更多相关阅读请进入《wordpress》频道 >>