【问题标题】:Bootstrap carasoul Indicator doesnot work引导轮播指示器不起作用
【发布时间】:2018-12-25 02:41:12
【问题描述】:

$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 之后显示一个指示器请帮助我哪里错了

这不显示结果请帮忙

【问题讨论】:

    标签: wordpress


    【解决方案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> 
    

    试试这个

    【讨论】:

    猜你喜欢
    • 2016-11-27
    • 2014-02-14
    • 2021-03-21
    • 2015-02-12
    • 1970-01-01
    • 2019-05-19
    • 2018-05-10
    • 1970-01-01
    • 1970-01-01
    相关资源
    最近更新 更多