这是我的页面的链接: http://list.thorsteinnhelgason.is/index.php/blog/
这是我的代码:
<div class="container">
<div id="content">
<?php
while ( have_posts() )
{
the_post();
?>
<h2><?php the_title(); ?></h2>
<?php the_content(); ?>
<?php
}
?>
</div>
这是我的Single.php文件的循环,它没有在我的帖子网站上显示任何帖子内容。我是否需要在其他模板(functions.php例如)中调用该操作以获取我的帖子内容?或者它可能是什么原因导致它不起作用?希望你能帮我...
创建一个'if'语句来检查帖子是否存在(在'while'之前)。然后记得关闭/结束你的'while'和'if'循环。
<div class="container">
<div id="content">
<?php if (have_posts()) : while (have_posts()) : the_post(); ?>
<h2><?php the_title(); ?></h2>
<?php the_content(); ?>
<?php
endwhile;
endif;
?>
</div>
</div>