single.php循环输出重复项


single.php loop outputs duplicates

我的博客文章有时会在多个实例中输出。这种情况是随机发生的,但当它发生时,我唯一的解决方案是删除帖子并再次转发。

这个问题可以在这里看到:http://experienceinvest.com/british-student-housing-investment-to-hit-5-75bn/

我的single.php文件:

<?php if ( have_posts() ) { the_post(); rewind_posts(); }  ?>
<?php
if ('investment' == get_post_type()) { include("investment-single.php");}
else { include("news-single.php"); }
?>

解决方案:

single.php单个模板文件的内容,在本例中为invstment-single.php&news-single.php需要封装在下面的循环中。

<?php if ( have_posts() ) : the_post(); rewind_posts(); ?>
<!--The page content goes here-->
<?php endif; ?>