2011-02-12 34 views
0

我有一個清單,像一個循環中產生:在迭代循環整數作爲一個類名

<?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> 

回答

2

剛剛轉會到$count=0以上while循環。

+0

OOp!太好了,謝謝..喜歡簡單的:) – Zac 2011-02-12 13:30:47