封装了下get_header();核心是get_template_part();
/**
* different header
*/
function st_get_header($name=null){
if(''!=$name){
get_template_part('templates/header/header',$name);
}else{
get_header();
}
}
说明1:可以做成不同页面,显示不同的header风格。
一开始我想这么做,后来发现用来用去就是一个header,干脆去掉了,回到get_header,只留一个header.php,简单点。
其他需要的小伙伴可以拿去用。
说明2:wp内置的get_header也可以调用多个header模板,但是大家都放在主题主文件下,移到其他文件夹下就不识别。这个函数完善了模板地址,放在templates/header/文件夹下。
说明3:wp主题文件夹结构:
assets/放css,js,img,fonts
inc/放扩充函数,避免functions.php塞得太多
templates/
modules/