wordpress函数get_header()的妙用

wordpress函数get_header()的妙用—不同页面调用不同头部信息。 说明 该函数从当前主题文件夹中包含header.php模板文件。如果指定名称,那么函数将包含一个特殊的头部文件header-special.php。如果主题中没有header.php文件,那么函数会包含默认主题wp-content/the...

wordpress函数get_header()的妙用—不同页面调用不同头部信息。 说明 该函数从当前主题文件夹中包含header.php模板文件。如果指定名称,那么函数将包含一个特殊的头部文件header-special.php。如果主题中没有header.php文件,那么函数会包含默认主题wp-content/themes/default/header.php的头部文件。

用法 <?php get_header( $name ); ?>

参数 $name

(字符串)(可选)对header-name.php的调用

默认值:None

示例 包含非默认头部文件

<?php get_header(‘myheader’); ?>

简单的404页面

下面是一个为“HTTP 404: Not Found”错误(在主题文件中为404.php)而制作的简单模板。

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

多个头部

不同页面的不同头部信息

<?php if ( is_home() ) : get_header(‘home’); elseif ( is_404() ) : get_header(’404′); else : get_header(); endif; ?>

wordpress函数get_header()的妙用—不同页面调用不同头部信息。

给TA打赏
共{{data.count}}人
人已打赏
wordpress教程

WordPress 创建配置文件 点击没反应解决方法

2023-2-16 15:49:44

wordpress教程

WordPress异步加载JS代码版

2023-2-16 15:49:45

【腾讯云】11.11云上盛惠!云服务器首年1.8折起,买1年送3个月!
11.11云上盛惠!海量产品·轻松上云!云服务器首年1.8折起,买1年送3个月!超值优惠,性能稳定,让您的云端之旅更加畅享。
查看更多相关信息>>
站长

(工作日 10:00 - 22:30 为您服务)

2026-03-27 20:54:25

您好,无论是售前、售后、意见建议……均可通过联系工单与我们取得联系。

猜你想问:

  • 购买的模板免费包安装吗?

  • 这个演示地址有吗?

  • 购买vip会员可以下载哪些模板?

您的留言我们已经收到,我们将会尽快跟您联系!
取消
立即选择任一渠道联系我们