引导carasoul指示器不起作用

时间:2018-07-17 11:49:00

标签: wordpress

$ data = new WP_Query(array('post_type'=>'myposttype','category'=> 1,'posts_per_page'=> -1,));     if($ the_query-> have_posts()){

  while ( $the_query->have_posts() ) {
    $data->the_post();

    echo '<li data-target="#id" data-slide-to="8" class="new"></li>';

  }
  wp_reset_postdata(); 
}  ?>

上面的代码显示的“轮播指示器”等于帖子数,我希望它在4点后显示一个指示器,请在出现错误的地方提供帮助

这没有显示结果,请帮助

1 个答案:

答案 0 :(得分:1)

    <ol class="carousel-indicators">
<?php $the_query   = new WP_Query( array( 'post_type' => 'myposttype' ,'category' => 1 , 'posts_per_page' => -1,) ); 
if ( $the_query->have_posts() ) {
  $j = 0;
  while ( $the_query->have_posts() ) {
    $j++;

    $the_query->the_post();

    }  ?>
   <li data-target="#myCarousel" data-slide-to=" <?php echo $j ?>" class=" <?php if($j==1) {echo 'active';} ?>"></li>';
  <?php}
  wp_reset_postdata(); 
}  ?>
</ol> 

尝试