live blog
我刚刚实现了一个新的自定义主题。我注意到我的帖子现在都显示在一个又一个的上面,我不知道为什么。为了测试我的代码,我将自定义循环替换为普通的Wordpress循环-问题仍然存在。我还禁用了每个插件,问题仍然存在。有没有办法修复?
<?php
/*
Template Name: Blog
*/
?>
<?php get_header();?>
<div id="blog-container">
<div class="content">
<?php get_sidebar( \'blog\');?>
<?php if(have_posts()) : while(have_posts()) : the_post(\'\'); ?>
<div class="meta">
<h3><a href="<?php the_permalink(); ?>"><?php the_title(); ?></h3>
<p><span style="font-size:85%"><?php the_tags(\'tags: \', \', \', \'<br />\'); ?> | <?php comments_number( \'no responses\', \'one response\', \'% responses\' ); ?> comments</span></p>
</div><!-- end meta -->
<div class="post">
<?php the_content(\'read more...\'); ?>
</div><!-- end post -->
<div class="share">
<span class="left-border"></span><!-- end border -->
<p style="font-family:nevis-webfont;">SHARE THIS POST</p>
<span class="right-border"></span><!-- end border -->
</div><!-- end share -->
</div><!-- end content -->
<?php endwhile; ?>
<?php else : ?>
<p>I\'m not sure what you\'re looking for.</p>
<?php endif; ?>
</div><!-- end blog-container -->
<?php get_footer();?>
最合适的回答,由SO网友:Vinod Dalvi 整理而成
您已经关闭了if语句中包含内容类的div,这会导致中断嵌套标记,而不是在if语句外部关闭它,如下所示。
<?php
/*
Template Name: Blog
*/
?>
<?php get_header();?>
<div id="blog-container">
<div class="content">
<?php get_sidebar( \'blog\');?>
<?php if(have_posts()) : while(have_posts()) : the_post(\'\'); ?>
<div class="meta">
<h3><a href="<?php the_permalink(); ?>"><?php the_title(); ?></h3>
<p><span style="font-size:85%"><?php the_tags(\'tags: \', \', \', \'<br />\'); ?> | <?php comments_number( \'no responses\', \'one response\', \'% responses\' ); ?> comments</span></p>
</div><!-- end meta -->
<div class="post">
<?php the_content(\'read more...\'); ?>
</div><!-- end post -->
<div class="share">
<span class="left-border"></span><!-- end border -->
<p style="font-family:nevis-webfont;">SHARE THIS POST</p>
<span class="right-border"></span><!-- end border -->
</div><!-- end share -->
<?php endwhile; ?>
<?php else : ?>
<p>I\'m not sure what you\'re looking for.</p>
<?php endif; ?>
</div><!-- end content -->
</div><!-- end blog-container -->
<?php get_footer();?>