有没有办法从多个容器中的单个循环输出帖子?理想情况下,我希望帖子标题/元数据/内容等在第一个容器和第二个容器之间交替出现,但我想不出没有多个循环的方法。
<?php
$paged = (get_query_var(\'paged\')) ? get_query_var(\'paged\') : 1;
query_posts(\'posts_per_page=3&paged=\' . $paged);
?>
<?php if (have_posts()) : while ( have_posts()) : the_post(); ?>
<div <?php post_class(\'clearfix\') ?> id="post-<?php the_ID(); ?>">
<h2><a href="<?php the_permalink() ?>"><?php the_title(); ?></a></h2>
<div class="first-container">
<?php global $more; $more = 0; ?>
<?php the_post_thumbnail(); ?>
<?php the_content(\'Read on...\'); ?>
</div> <!-- end div first-container -->
</div> <!-- end div post/clearfix -->
已满
<?php
$paged = (get_query_var(\'paged\')) ? get_query_var(\'paged\') : 1;
query_posts(\'posts_per_page=3&paged=\' . $paged);
?>
<?php $class = \'\';
<?php if (have_posts()) : while ( have_posts()) : the_post(); ?>
<?php $class = (\'first-container\' == $class) ? \'second-container\' : \'first-container\'; // alternate classes ?>
<div <?php post_class(\'clearfix\') ?> id="post-<?php the_ID(); ?>">
<div class="metawrapper">
<div class="leftmeta">
<div class="date-house">
<span><?php the_time(\'M jS, Y\') ?></span>
</div> <!-- end div date house -->
</div> <!-- end div leftmeta -->
<div class="meta">
<?php echo \'<em>Written by </em> <br>\'; the_author_posts_link(); ?>
<?php the_tags(\'Tags: \', \', \', \'<br />\'); ?>
</div> <!-- end div meta -->
<div class="commentsbutton">
<span>Comments</span>
<?php comments_popup_link(\'No Comments\', \'1 Comment\', \'% Comments\', \'comments-link\', \'\'); ?>
</div> <!-- end div commentsbutton -->
</div> <!-- end div metawrapper -->
<div class="entrywrapper">
<div class="entry">
<div class="bordertop">
<h2><a href="<?php the_permalink() ?>"><?php the_title(); ?></a></h2>
</div> <!-- end div bordertop -->
<?php global $more; $more = 0; ?>
<?php the_post_thumbnail(); ?>
<div class="spacersingle"></div> <!-- end div spacersingle -->
<?php the_content(\'Read on...\'); ?>
<div class="postbreaker"></div> <!-- end div entrybreaker -->
</div> <!-- end div entry -->
<div class="<?php echo $class ?>">
<div style="clear:both"></div>
</div> <!-- end div entrywrapper -->
<div style="clear:both"></div>
</div> <!-- end div post -->
<?php endwhile; endif; ?>