2016-08-21 91 views
0

我使用JointsWP为我为客户创建的Wordpress网站。交替的WordPress的帖子

他们希望帖子在帖子循环时交替。

例如,POST1:特征图像在左侧,标题/摘录在右侧; POST2:左侧的标题/摘录,右侧的特征图像。等等

有没有人发现这样的运气?

<?php 
$args = array('posts_per_page' => 2, 'offset' => 2,); 
$myposts = get_posts($args); 
foreach ($myposts as $post) : setup_postdata($post); ?> 
<div class="row"> 
<div class="large-6 columns"> 
<a href="<?php the_permalink(); ?>"> 
<?php the_post_thumbnail(); ?> 
</a> 
</div> 
<div class="large-6 columns"> 
<?php the_date(); ?> 
<a href="<?php the_permalink(); ?>"> 
<h3><?php the_title(); ?></h3> 
</a> 
<?php the_excerpt(); ?> 
</div> 
<div class="large-12 columns"> 
<hr> 
</div> 
</div> 

<?php endforeach; wp_reset_postdata();?> 
+1

'$ myposts'是关联数组还是索引数组? –

+0

它被设置为一个关联数组。 –

回答