我第一次构建一个主题,使用Bootstrap 3与Wordpress集成来实现。我有一个旋转木马部分工作。现在,它按相反的顺序显示幻灯片,即幻灯片3、幻灯片2、幻灯片1。然后它中断并转到一个空白屏幕。
这是我正在使用的代码。你知道为什么会发生这种情况吗?或者我可以试着让它以正确的顺序运行并无限循环吗?
<div class="container">
<div id="carousel-example-generic" class="carousel slide" data-ride="carousel">
<!-- Indicators -->
<ol class="carousel-indicators">
<li data-target="#carousel-example-generic" data-slide-to="0" class="active"></li>
<li data-target="#carousel-example-generic" data-slide-to="1"></li>
<li data-target="#carousel-example-generic" data-slide-to="2"></li>
</ol>
<!-- Wrapper for slides -->
<div class="carousel-inner">
<?php $new_query = new WP_Query(\'post_type=slide&posts_per_page=3\');
$i = 1;
while ( $new_query->have_posts()) : $new_query->the_post(); ?>
<div class="item <?php if ($i == 1) echo \'active\'; ?>" >
<img src="<?php the_field(\'slide_image\'); ?>" >
<div class="carousel-caption">
<h1><small><?php the_field(\'slide_caption\'); ?></small></h1>
</div><!--carousel-caption-->
</div><!--item active -->
<?php
$i++;
endwhile;
wp_reset_postdata();
?>
<!-- Controls -->
<a class="left carousel-control" href="#carousel-example-generic" data-slide="prev">
<span class="glyphicon glyphicon-chevron-left"></span>
</a>
<a class="right carousel-control" href="#carousel-example-generic" data-slide="next">
<span class="glyphicon glyphicon-chevron-right"></span>
</a>
</div>