【发布时间】:2016-10-10 13:55:14
【问题描述】:
按照本教程: http://blog.teamtreehouse.com/responsive-wordpress-bootstrap-theme-tutorial
教程指导我创建一个 index.php 的内容:
<?php get_header(); ?>
<!-- loop-->
<?php if ( have_posts() ) : while ( have_posts() ) : the_post(); ?>
<h1><?php the_title(); ?></h1>
<?php the_content(); ?>
<?php endwhile; else: ?>
<p><?php _e('Sorry, no posts matched your criteria.'); ?></p>
<?php endif; ?>
<?php get_footer(); ?>
这将创建一个模板,顶部是我的页眉,底部是页脚。然后,教程指示我创建一个包含以下内容的 front-page.php:
<?php if ( have_posts() ) : while ( have_posts() ) : the_post(); ?>
<?php the_content(); ?>
<?php endwhile; else: ?>
<p><?php _e('Sorry, no posts matched your criteria.'); ?></p>
<?php endif; ?>
基本上,与 index.php 相同的内容减去几行代码,最重要的是 <?php get_header(); ?> 和 <?php get_footer(); ?> 命令。问题是,当我创建这个页面时,我的首页不再有页眉或页脚,或者页眉和页脚中的格式。
然而,在教程中,页眉、页脚和格式仍然适用于首页。我做错了什么?
【问题讨论】:
-
我认为教程的人忘记了这行。只需将
get_header();和get_footer();保留在您的front-page.php中即可。