我拥有的当前代码正在渲染额外div
的 . 你能帮我如何使它正确吗?
每 3 个项目将在一个div
带有item
类的内部,第一个项目将具有active
类。
<!-- Carousel items -->
<div class="carousel-inner">
<div class="item active">
<div class="row">
<?php
$args = array(
'post_type' => 'product',
'product_cat' => 'Featured',
'posts_per_page' => 12
);
$loop = new WP_Query( $args );
if ( $loop->have_posts() ) {
$postcount = 0;
$i = 1;
while ( $loop->have_posts() ) : $loop->the_post();
$postcount ++;
?>
<div class="col-md-4 item-entry-index">
<div class="car-index">
<img src="<?php echo get_the_post_thumbnail_url($loop->post->ID); ?>" class="img-responsive" alt=""/>
</div>
</div>
<?php
if ( $i % 3 === 0 ) {
echo '</div></div><div class="item"><div class="row">';
}
?>
<?php
$i++;
endwhile;
} else {
echo __( 'No products found' );
}
wp_reset_postdata();
?>
</div>
</div>
</div><!--.carousel-inner-->