Css 带$count的Div类名;在wordpress循环中
我需要添加一个$count;在循环中的一个post div的classname之后。意思示例:-所以帖子的类将是mypost1、mypost2 我做得很好,但我不知道如何在类名后添加$countCss 带$count的Div类名;在wordpress循环中,css,wordpress,loops,Css,Wordpress,Loops,我需要添加一个$count;在循环中的一个post div的classname之后。意思示例:-所以帖子的类将是mypost1、mypost2 我做得很好,但我不知道如何在类名后添加$count <?php $count = 0; if ( have_posts() ) : while ( have_posts() ) : the_post(); $count++; ?> <div class="mypost">...</div> <?php endwh
<?php $count = 0; if ( have_posts() ) : while ( have_posts() ) : the_post(); $count++; ?>
<div class="mypost">...</div>
<?php endwhile; endif; ?>
...
简单地将变量回送到适当的位置:
<?php $count = 0; if ( have_posts() ) : while ( have_posts() ) : the_post(); $count++; ?>
<div class="mypost<?php echo $count; ?>">...</div>
<?php endwhile; endif; ?>
@MichalBěhal不用担心。