GeekerCode更好的WordPress主题,值得信任的WordPress主题开发商

极美的主题、极致的插件

WordPress get_header()头部文件函数

摘要:【函数介绍】我们都知道PHP经常会使用到include来引用PHP文件,wordpress为了简化这些常用文件的引用,特别为我们准备了 get_header()、get_footer()、get_sidebar()等主题模板文件包含语句。g

【函数介绍】

我们都知道PHP经常会使用到include来引用PHP文件,wordpress为了简化这些常用文件的引用,特别为我们准备了 get_header()、get_footer()、get_sidebar()等主题模板文件包含语句。get_header()函数是我们主题开发过程必用的函数,一般用于包含公用的头部文件header.php,如果你有多个头部文件你可以使用get_header($name)来获取指定头部文件header-{$name}.php。

【函数使用】

<?php get_header( $name ); ?>

【参数说明】

$name

(string) (可选) 获取指定头部文件,格式为header-name.php.

默认: None

【参数实例】

404页面设置:

<?php get_header(); ?>
<h2>Error 404 - Not Found</h2>
<?php get_sidebar(); ?>
<?php get_footer(); ?>

多个头部,获取主题中的头部文件header-test.php:

$name = 'test';
<?php get_header('test'); ?>

建站!你有充足的理由选择我们

世界上超过30%的网站是由WordPress搭建,而我们是国内最靠谱的WordPress主题开发商
QQ咨询在线咨询问答互助微信号geekercode微信公众号云服务器