2016-05-25 2 views
0

ACF WordPressプラグインを使用していますが、PHPが正常に動作しません。私は声明のためにそれを使用しています。このように見えるように仮定されていますWPは2つではなく1つのフィールドのみを表示するカスタムフィールドループを拡張しました

enter image description here

私はほとんどそこだが、何が起こっていることはそれがに各ループの代わりに、2一つだけ証言を見せています。これは私のPHPです:

<ul class="orbit-container"> 

     <?php 
      $count = 0; 
      while (have_rows('testimonials')) { 
       the_row(); 

       $image = get_sub_field('avatar'); 
       $content = get_sub_field('content'); 
       $name = get_sub_field('name'); 

       if ($count > 0 && ($count % 2 == 0)) { 
      ?> 

      <?php } ?> 

      <li class="orbit-slide is-active"> 
      <div class="bubble"> 
       <img src="<?php echo $image; ?>" alt="Testimonials" /> 
       <?php echo $content; ?> 
       <span><?php echo $name; ?></span> 
      </div> 
      </li> 

      <?php $count++; }?> 

     </ul> 
+0

'have_rows()'と 'get_sub_field()'がどのように定義されているかを表示できますか? –

答えて

0

私はifを追加し、彼らは間違った場所にあったので、htmlタグの周りに移動しました。これは今のようになります:

<div class="orbit" role="region" aria-label="Testimonials" data-orbit> 
    <?php 
     if (have_rows('testimonials')) { $count = 0; ?> 
     <ul class="orbit-container"> 

     <?php while(have_rows('testimonials')) { 
      the_row(); 

      $image = get_sub_field('avatar'); 
      $content = get_sub_field('content'); 
      $name = get_sub_field('name'); 

      if ($count % 2 == 0) { 
      ?> 

      <li class="orbit-slide"> 
      <?php } ?> 

      <div class="bubble"> 
       <img src="<?php echo $image; ?>" alt="Testimonials" /> 
       <?php echo $content; ?> 
       <span><?php echo $name; ?></span> 
      </div> 

      <?php $count++; } ?> 
      </li> 

     </ul> 
    <?php } ?> 
    </div> 
</div> 
関連する問題