帖子显示在同一个div Wordpress中

时间:2013-06-24 20:59:16

标签: wordpress wordpress-theming

我的所有帖子都显示在同一个div中,而不是单独的帖子,

<?php get_header(); ?>
 <div class="mainwrap">
 <div class="bloginner">
 <!-- begin section -->           

<section>
    <div class="postswrap">
    <?php if (have_posts()) : while (have_posts()) : the_post(); ?>
    <div class="commentsetall"><img src="<?php bloginfo('template_url'); ?>/images/ico_folder.png" alt="Posted" /><span class="commentfix"><?php the_time('F j, Y') ?> in <?php the_category(', ') ?> by <?php the_author() ?></span></div>
    <h1><a href="<?php the_permalink(); ?>"><?php the_title(); ?></a></h1>
    <?php endwhile; else: ?>
    <p><?php _e('Sorry, no posts matched your criteria.'); ?></p>
    <?php endif; ?>
    <div class="clearfix"></div>
    </div>

</section>
<!-- end section -->
 </div> 
<div class="clearfix"></div>
</div>
<?php get_footer(); ?>

是否可能缺少一个clearfix来阻止这种情况发生?

感谢

1 个答案:

答案 0 :(得分:3)

<div class="postswrap">放在loop.something中:

       <?php if (have_posts()) : while (have_posts()) : the_post(); ?>
 <div class="postswrap">
        <div class="commentsetall"><img src="<?php bloginfo('template_url'); ?>/images/ico_folder.png" alt="Posted" /><span class="commentfix"><?php the_time('F j, Y') ?> in <?php the_category(', ') ?> by <?php the_author() ?></span></div>
        <h1><a href="<?php the_permalink(); ?>"><?php the_title(); ?></a></h1>
        <?php endwhile; else: ?>
        <p><?php _e('Sorry, no posts matched your criteria.'); ?></p>
<div class="clearfix"></div>
        </div>        
<?php endif; ?>