2016-01-31 135 views
0

我試圖進一步,新的圖像鏈接加載顯示。WordPress的貓頭鷹旋轉木馬添加圖片問題 - PHP

當前顯示5個,但我們希望將來可能添加第六個&,也許2或3個。

我們遇到的問題是,當我們添加了第六,它覆蓋的一個現有的5

任何人都可以有幫助,我懷疑是功能,讓我們添加更多?

感謝

HTML

<div class="content"> 
<div class="visible-xs visible-sm" style="background: #367586;color: white;width: 100%;"> 
    <h2 style="color: white;padding: 20px;text-align: center;">Call us on <a style="text-decoration: none;color: white;" href="tel:0141999999">0131 344 4146</a></h2> 
</div> 
<div class="pageTitle"> 
    <h1><?php single_cat_title(); ?></h1> 
</div> 

<?php 
    $posts = get_posts('category='.$cat); 
    vvwc_carouselList($posts); 
?> 

<div class="clearfix"></div> 

PHP

function vvwc_carouselList($posts, $postId=null){ 
if(!empty($posts)){ 
    echo ' 
     <div class="nonCarousel"> 
      <ul class="list-inline"> 
    '; 
     $x = 1; 
     foreach($posts as $post){ 
      $active = ''; 
      $feature = ''; 
      if($postId == $post->ID){ 
       $active = 'active'; 
       $feature = 'feature'; 
      } 
      if($x == 5 || $x == 1){ 
       ?> 
       <div class='row'> 
       <?php 
      } 
      echo ' 
       <li class="col-md-3 '.$feature.'"> 
        <div class="'.$active.' carousel-border"> 
         <div class="carousel-item"> 
         <a data-item="'.$post->ID.'" href="'.get_permalink($post->ID).'"> 
       '; 
          if(has_post_thumbnail($post->ID)){ 
           echo get_the_post_thumbnail($post->ID); 
          } 
          echo "<div class='camperTitle'>" . strtoupper($post->post_title) . "</div>"; 
       echo ' 
          </a> 
         </div> 
        </div> 
       </li> 
      '; 

      if($x == 4 || $x == count($posts)+1){ 
       ?> 
       </div> 
       <?php 
      } 
      $x ++; 
     } 
    echo ' 
      </ul> 
      <div class="clearfix"></div> 
     </div> 
    '; 
} 
echo ' 
    <div class="clearfix"></div> 
    <script> 
     jQuery(document).ready(function($){ 
      $(".carousel ul").owlCarousel({ 
       items: 4, 
       pagination: false, 
       navigation: true, 
       navigationText: false, 
       slideSpeed: 1000, 
       rewindSpeed: 1000 
      }); 
     }); 
    </script> 
'; 

}

+0

嘗試設置'items'至6 – Fabricator

回答

0

找到了,我代替:

$posts = get_posts('category='.$cat);

$posts = get_posts(array( 'category' =>15, 'orderby' => 'title', 'posts_per_page'=> 10, 'order' => 'ASC', ));

相關問題