有关Get_header函数的调用

技术流评论3,304阅读模式

WordPress的Get_header函数用法。

这个函数,默认调用的是同级别下(一般都是themes文件下)的header.php。文章源自原紫番博客-https://www.yuanzifan.com/55600.html

当然有的主题没有header.php,那就引入wp-includes/theme-compat/header.php文章源自原紫番博客-https://www.yuanzifan.com/55600.html

都没有的话,那这个函数什么都不会调出来的。文章源自原紫番博客-https://www.yuanzifan.com/55600.html

如果你要给一个特定也页面写一个特定的页头,那么就要在themes下同级别目录写一个header-XXXX.php文件。也就是header-,这个中划线之后的才是能调用的。文章源自原紫番博客-https://www.yuanzifan.com/55600.html

比如下图header-Single,那我写好了文件,调用的时候就应该是get_header('Single');文章源自原紫番博客-https://www.yuanzifan.com/55600.html

不用写文件全名,不用加PHP后缀,这是wordpress的内置函数写好的方法。文章源自原紫番博客-https://www.yuanzifan.com/55600.html

文章源自原紫番博客-https://www.yuanzifan.com/55600.html 文章源自原紫番博客-https://www.yuanzifan.com/55600.html

 

发表评论

匿名网友
:?: :razz: :sad: :evil: :!: :smile: :oops: :grin: :eek: :shock: :???: :cool: :lol: :mad: :twisted: :roll: :wink: :idea: :arrow: :neutral: :cry: :mrgreen:
确定

拖动滑块以完成验证