在WordPress中的图像卡鲁塞尔

时间:2019-07-17 08:35:24

标签: wordpress carousel gallery

我正在使用wordpress,我想用这样的自举程序创建一个caroussel

https://imgur.com/JsPPxsS

这是我页面中的结果 https://imgur.com/GvVzqIN

问题是我的“帖子”显示3次而不是1次

这是我的一些代码

     $out = "";
     $x= 1;
     $script = "";
     $out .='<div class="container">
        <div class="row">';
        $out.='
                <div class="col-md-12 center-block">
              <div class="carousel slide poles 
    color_'.$i.'" id="myCarousel">
                <div class="carousel-inner">';
while($query->have_posts())
{
    $query->the_post();
    $lire = get_post_meta(get_the_ID(),'lire',true);
    $inscriver_vous = 
     get_post_meta(get_the_ID(),'inscriver_vous',true);
    $icon = get_post_meta(get_the_ID(),'icon',true);
    $title = explode(" ",get_the_title());
    $title1 = $title[0];
    $title2 = 
     substr(get_the_title(),strlen($title1),strlen(get_the_title()));
    $date = get_post_meta(get_the_ID(),'date_inscription',true);
    $color = get_post_meta(get_the_ID(),'code_couleur',true);

                $pole = get_posts();
                foreach ($pole as $poles) {
                    if($x==1)
                    {
                        $active="active";
                    }
                    else {
                        $active="";
                    }
                $out.='<div class="item '.$active.'">
                                <div 
       class="col-xs-4 pole-img-box">

       <img src="'.get_the_post_thumbnail_url().'" alt="">

        <div class="pole-box-hover">

        <p>'.get_the_content().'</p>';

        if (!empty($date)) {

         $out.='<p class="pole-date">

       <span><i class="fa fa-calendar"></i>Concours d\'admission : 
       '.date_show($date).'</span>

     </p>';                                      
         }                                           
          $out.='                                                            
     <a class="btn bg-white" href="'.$inscriver_vous.'">Inscrivez-vous</a>                                       
     <a class="btn bg-blue" href="'.$lire.'">Lire la suite</a>

     </div>

     <div class="pole-box-titre">

     <h3>'.$title1.'</h3>

     <p>'.$title2.'</p>

     </div>

     <div class="pole-box-logo">

    <img src="../'.$icon.'" alt="">

     </div>

    </div>

    <span class="box-toggle"></span>
                        </div>';
          $x++;
          }
          ?>
          <?php

$script .= ".upm_color_".$i." .pole-img-box:before{ 
     background:".hexToRgb($color)."}";
}
$out.='
              </div>
                  <a class="carousel-control left" 
    href="#myCarousel" data-slide="prev">
                    <span class="glyphicon glyphicon- 
    chevron-left"></span>
                </a>
                <a class="carousel-control right" 
     href="#myCarousel" data-slide="next">
                    <span class="glyphicon glyphicon- 
     chevron-right"></span>
                </a>
              </div>            
            </div>';
   $out.='</div> </div>';
echo $out;

有解决方案吗? 谢谢。

0 个答案:

没有答案