2013-03-20 17 views
0

我需要一個滑塊在一個循環中工作,我使用下面的代碼我們如何使用滑塊一個循環中

while (have_posts()) : the_post(); ?> 
<div id="content"> 




<?php 


$attachments = get_children(array(
    'post_parent' => $post->ID, 
    'post_type' => 'attachment', 
    'order' => '', 
    'post_mime_type' => 'image') 
    ); 
echo "aaaaa".count($attachments); 
?> 


<?php if(count($attachments)!=0){ ?> 
<div id="portfolio-gallery"> 
    <ul id="slideshow_detail"> 
     <?php 
     foreach ($attachments as $att_id => $attachment) { 
     $getimage = wp_get_attachment_image_src($att_id, 'room-gallery', true); 
     $roomimage = $getimage[0]; 
     echo '<li> 
     <h3></h3> 
     <span>'.$roomimage.'</span> 
     <p></p> 
     <img src="'.$roomimage.'" alt="" class="thumb-slide" /> 
     </li>'; 
     } 
     ?> 
    </ul> 

    <div id="wrapper1"> 
     <div id="fullsize"> 
      <div id="imgprev" class="imgnav" title="Previous Image"></div> 
      <div id="imglink"></div> 
      <div id="imgnext" class="imgnav" title="Next Image"></div> 
      <div id="image"></div> 
      <div id="information"> 
       <h3></h3> 
       <p></p> 
      </div> 
     </div> 
     <div id="thumbnails"> 
      <div id="slideleft" title="Slide Left"></div> 
      <div id="slidearea"> 
       <div id="slider-room"></div> 
      </div> 
      <div id="slideright" title="Slide Right"></div> 
     </div> 
    </div> 
<script type="text/javascript" src="http://ajax.googleapis.com/ajax/libs/jquery/1.4.2/jquery.min.js"></script> 
<script type="text/javascript"> 
<!-- 

    $('slideshow_detail').style.display='none'; 
    $('wrapper1').style.display='block'; 
    var slideshow_detail=new TINY.slideshow_detail("slideshow_detail"); 
    window.onload=function(){ 

     slideshow_detail.auto=true; 
     slideshow_detail.speed=5; 
     slideshow_detail.link="linkhover"; 
     slideshow_detail.info="information"; 
     slideshow_detail.thumbs="slider-room"; 
     slideshow_detail.left="slideleft"; 
     slideshow_detail.right="slideright"; 
     slideshow_detail.scrollSpeed=4; 
     slideshow_detail.spacing=25; 
     slideshow_detail.active="#fff"; 
     slideshow_detail.init("slideshow_detail","image","imgprev","imgnext","imglink"); 
    } 
//--> 
</script> 
</div> 
<?php endwhile;?> 

通過使用此代碼滑塊工作只有一次,我需要工作滑塊在一個循環下。 即我要添加多個崗位,每個崗位有。我有使用滑塊

+0

您在每個while循環中包含JS。所以如果它有效,它會被多次註冊。將你的JS移出循環。 – janw 2013-03-20 10:50:00

回答

0

顯示每個崗位的細節和每個崗位的顯示圖像的多張圖片,我覺得也許是while循環,開始在頂部可能成爲問題。爲什麼不使用if語句。我不熟悉你的「while」語法。我只看過以下:

<?php while(someCondition()): ?> 

    //statements in here 

<?php endwhile; ?> 

或者,也許嘗試的if語句來代替:

<?php if (have_posts()): ?> 
    //all slider code here 
<?php } else { ?> 
    //give a 'there are no posts' message 
<?php endif; ?> 

亦是WordPress插件,你運行?不知道這個問題,要解決這個問題有點困難。

+0

http://themomenthotel.com/new/los-angeles-accommodations/通過使用上面的代碼滑塊只適用於一個職位。在剩餘的職位圖像逐一顯示 – 2013-03-21 11:51:12