2011-09-20 78 views

回答

5

您是否嘗試過使用%運算符。像下面這樣(未經):

if(have_posts()) : 
$i=0; 
while ($wp_query->have_posts()) : $wp_query->the_post(); 
$i++; 
?> 
<li <?php if(($i % 3)==0)echo 'style="background:green"';?>>Test</li> 
<?php endwhile; ?> 
<?php endif; 

PHP參考:http://php.net/manual/en/language.operators.arithmetic.php