在WordPress主题里可以根据特别的分类、文章、存档等自主地选择特殊调用显示的header、footer和sidebar文件。
其中只需要做一个判断,(WordPress主题中的判断函数)如
<?php if is_category('WordPress') {
get_header('wordpress');
} else {
get_header();
} ?>
以上代码判断读者是否在”WordPress”分类里,如果是,将使用header-wordpress.php,否则使用默认header。
同样,你可以用这个方法加载指定的footer和sidebar:如
<?php get_footer('otherfooter'); ?>
引入otherfooter.php文件
<?php get_sidebar('othersidebar'); ?>
引入othersidebar.php文件