Php 在循环中将整数作为类名迭代

Php 在循环中将整数作为类名迭代,php,wordpress,Php,Wordpress,我有一个列表正在生成,循环如下: <?php $the_query = new WP_Query('cat=40&showposts=10'); while ($the_query->have_posts()) : $the_query->the_post();?> <?php $my_post = get_post($post_id); $title = $my_post->post_title; $count = 0; $count ++; ech

我有一个列表正在生成,循环如下:

<?php $the_query = new WP_Query('cat=40&showposts=10');
while ($the_query->have_posts()) : $the_query->the_post();?>
<?php
$my_post = get_post($post_id);
$title = $my_post->post_title;
$count = 0;
$count ++;
echo '<li class="name-'.$count.'">';
echo '<li>' .$title.'</li>';
?>

有人能帮我把一个整数作为类名附加吗。。因此,输出类似于:

<li class="name-1">title</li>
<li class="name-2">title</li>
标题 标题 我上面的代码刚刚返回:

<li class="name-1">title</li>
<li class="name-1">title</li>
标题 标题
只需在循环时将$count=0移动到上方即可