我想留在WordPress的同一轮循环,第一个帖子将有6列,其他帖子将在6列。例如http://prntscr.com/mvx453我的HTML代码https:// PasteBin。低/ uQvcsP8h
<?php
// checks if there are any posts that match the query
if (have_posts()) :
$i=1;
?>
<div class="col-md-6">
<?php
// If there are posts matching the query then start the loop
while ( have_posts() ) : the_post();
// the code between the while loop will be repeated for each post
?>
<h2 id="post-<?php the_ID(); ?>"><a href="<?php the_permalink() ?>" rel="bookmark" title="Permanent Link to <?php the_title(); ?>"><?php the_title(); ?></a></h2>
<p class="date-author">Posted: <?php the_date(); ?> by <?php the_author(); ?></p>
<?php if($i==1){ ?>
</div>
<div class="col-md-6">
<?php } ?>
<?php
$i++;
// Stop the loop when all posts are displayed
endwhile; ?>
</div>
<?php
// If no posts were found
else : ?>
<p>Sorry no posts matched your criteria.</p>
<?php endif; ?>