动态Bootstrap Carrousel

时间:2017-02-03 16:39:15

标签: php wordpress twitter-bootstrap while-loop slider

我试图在bootstrap carousel上创建whiles来打印图像。我正在学习。

我得到一个包含数据库网址的数组,而在显示正确的图像时我无法做到。

        <?php
            $this_post_id = get_the_ID();
            $urls =get_post_meta($this_post_id,'my-images', true);
            $totalUrls = count($urls);//count urls in array
            $number = 0; 
        ?>      


  <div id="carousel-example-generic" class="carousel slide" data-ride="carousel">
  <!-- Indicators -->


  <ol class="carousel-indicators">
    <?php while($number <= $totalUrls){ ?>
    <li data-target="#myCarousel" data-slide-to="<?php echo $number++; ?>"></li>
    <?php } ?>
  </ol>

  <!-- Wrapper for slides -->
  <div class="carousel-inner" role="listbox">

    <?php while($number <= $totalUrls){
     foreach($urls as $url){
        ?>

            <div class="item active">
      <img src="<?php echo $url;?>"  class="img-responsive" />
      <div class="carousel-caption">
        ...
      </div>
    </div>
     <?php} } ?>
 </div>

由于

0 个答案:

没有答案