一聚教程网:一个值得你收藏的教程网站

最新下载

热门教程

wordpress怎么实现不同页面引入不同header文件

时间:2014-03-11 编辑:简简单单 来源:一聚教程网

wordpress主题一般会有header.php头部文件,但不同页面可能会有需要引入不同header文件的需要,实现代码如下:

 代码如下 复制代码

if ( is_home() ) :
get_header( 'home' );
elseif ( is_404() ) :
get_header( '404' );
else :
get_header();
endif;
?>

上述代码实现:首页引入header-home.php , 404页面引入header-404.php页面,若不存在上述要引入的页面,直接在主题文件夹内搜索引用头部通用文件header.php

热门栏目