我想在每兩個項目之後的while循環中添加一個div標籤。在一個while循環中包裝項目
我正在嘗試使用下面的代碼,但它在最後增加了一個額外的空<div></div>
。
$i = 0;
while (have_posts()) : the_post();
$i++;
if ($i == 1){$output .= "<div>";}
if ($i % 2 == 0){$output .= "</div><div>";}
endwhile;
if ($i % 2 != 0){$output .= "</div>";}
你的命令的項目細節在哪裏?它是在if語句還是之前? – shashwat
使用$ i的目的是什麼? – Techie