0
出於某種原因,我在查詢結果的末尾得到額外的<li> </li>
。我怎樣才能防止這種情況發生?PHP查詢結果添加額外<li></li>
<li>
<?php
$counter = 0;
$query = new WP_Query(array('post_type' => 'serivces'));
while ($query->have_posts()) : $query->the_post(); $counter++;
?>
<div class="col-md-4 wp4">
<h2 class="text-left"><?php the_title(); ?></h2>
<p class="text-left"><?php the_content(); ?></p>
</div>
<?php
if ($counter > 0 && $counter % 3 == 0) {
echo '</li><li>';
}
endwhile;
?>
</li>