Mic*_*hal 2 css wordpress loops
我需要加上$ count; 在循环内的classname到post div之后.意义的例子: - 所以帖子的类将是mypost1,mypost2 ......
我的工作正常,但我不知道如何在classname后添加$ count.
<?php $count = 0; if ( have_posts() ) : while ( have_posts() ) : the_post(); $count++; ?>
<div class="mypost">...</div>
<?php endwhile; endif; ?>
Run Code Online (Sandbox Code Playgroud)
只需echo
将您的变量放在适当的位置:
<?php $count = 0; if ( have_posts() ) : while ( have_posts() ) : the_post(); $count++; ?>
<div class="mypost<?php echo $count; ?>">...</div>
<?php endwhile; endif; ?>
Run Code Online (Sandbox Code Playgroud)