使用foreach循环我要输出foreach语句的结果,但我想他们组合成一个div 3的与反
所以像:
<div>image image image</div>
<div>image image image</div>
<div>image image image</div>
这里是我到目前为止的代码:
$args = array('numberposts' => 3, 'offset'=> 0, 'category' => 9);
$myrows = get_posts($args);
foreach($myrows as $row) { ?>
<div>
<?php if (has_post_thumbnail($row->ID)) {
echo '<a href="' . get_permalink($row->ID) . '" title="' . esc_attr($row->post_title) . '">';
echo get_the_post_thumbnail($row->ID);
echo '</a>';
}?>
</div>
<?php } ?>
使用一个临时变量并每三个循环重置一次。 – Voitcus 2013-04-08 13:27:03