2016-08-21 93 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

它被設置爲一個關聯數組。 –

回答