wordpress实现不同页面引入不同header文件的方法

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

<?php
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。

👋 感谢您的观看!

© 版权声明
THE END
喜欢就支持一下吧
点赞0 分享