2012-11-05 4 views
0

이것은 아마 이상하게 들리지만 (나에게 맞습니다) WordPress 이미지 슬라이드 쇼 (첨부 파일 사용)에서 이미지에 캡션이없는 경우 이전 다음 채워진 캡션이 나타날 때까지 화면에 캡션이 표시됩니다.슬라이드 쇼 캡션이 비어있는 경우 계속 표시됩니다.

가능 :/

도움을 주셔서 감사합니다.

+1

에 오신 것을 환영합니다! 너 뭐 해봤 니? 코드 스 니펫이없는 질문은 일반적으로 대답하기가 어렵습니다. –

+0

당신은 img 설명을 의미합니까? – loQ

+0

더 유용하지 않다는 사과, 나는 문제를 해결하고 아래에 하나의 해결책을 게시했습니다! – Ste

답변

0

이전에는 코드를 표시하지 않았기 때문에 지금은 분류되어 사과드립니다. 나와 함께 일한 해결책은 다음과 같습니다. 스택 오버플로

<?php endif; ?> 
    <?php if (have_posts()) : while (have_posts()) : the_post(); 
    $attachments = attachments_get_attachments(); 
    $total_attachments = count($attachments); 
     if($total_attachments > 0) : 
     for ($i=0; $i < $total_attachments; $i++) : ?> 
      <div><img src="<?php echo $attachments[$i]['location']; ?>" alt="<?php echo $attachments[$i]['caption']; ?>" title="<?php echo $attachments[$i]['title']; ?>"> 
      <?php if($attachments[$i]['caption']==""){ 
       $new_caption=$attachments[$i-1]['caption'];  
      }else{ 
       $new_caption=$attachments[$i]['caption']; 
      } 
      ?> 
      <h2 id="tagline" title="<?php echo $attachments[$i]['title']; ?>"><?php echo $new_caption; ?></h2> 
      </div> 
      <?php endfor; ?> 
      <?php endif; ?> 
    <?php endwhile; else: ?>