QQ咨询不加好友发不了信息,咨询前先加好友! → QQ:820896380 ×

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自动为附件图像添加灯箱弹窗效果[无插件版]

2023-2-16 15:49:46

个人中心
购物车
优惠劵
有新私信 私信列表
搜索