【发布时间】:2014-07-21 17:07:12
【问题描述】:
所以我有点迷路了。我已经设置了一个静态首页,将我的主页贴花为首页,它使用 index.php,并且我已将我的静态帖子页面声明为我的新闻和事件页面。
现在,每当我进行更改并尝试预览我的新闻和事件页面时,它都会使用我的 index.php 模板而不是我的 home.php(我的印象是静态帖子页面的默认模板) .
奇怪的是,每当我通过实际网站而不是预览导航到新闻和活动页面时,一切都正确显示并使用正确的 home.php 模板。所以,从本质上讲,一切都按照我想要的方式工作,但预览将我带到 index.php/我的主页(即使 URL 显示我应该预览正确的页面 ID)这一事实,已经我很担心。
这里是我的 index.php
<?php get_header(); ?>
<?php if ( have_posts() ) : while ( have_posts() ) : the_post(); ?>
<?php the_content(); ?>
<?php endwhile; else: ?>
<p><?php _e('Sorry, this page does not exist.'); ?></p>
<?php endif; ?>
<?php get_footer(); ?>
这里是我的家.php
<?php get_header(); ?>
<section id="news">
<div class="row">
<div class="container">
<div class="col-md-8">
<h1 style="margin-bottom:50px">News and Events</h1>
<?php if ( have_posts() ) : while ( have_posts() ) : the_post(); ?>
<h2><a href="<?php the_permalink(); ?>"><?php the_title(); ?></a></h2>
<p><em><?php the_time('l, F jS, Y'); ?></em></p>
<p>Category: <?php the_category(', ') ?></p>
<p><?php the_tags(); ?> </p>
<hr>
<?php the_excerpt(); ?>
<?php comments_template() ?>
<?php endwhile; else: ?>
<p><?php _e('Sorry, there are no posts.'); ?></p>
<?php endif; ?>
</div>
<div class="col-md-4" style="margin-bottom:50px">
<?php get_sidebar(); ?>
</div>
</div>
</div>
</section>
<?php get_footer(); ?>
提前感谢您的帮助!
【问题讨论】: