【问题标题】:Trying to to call specific Advanced Custom Fields repeater field inside Bootstrap tab尝试在 Bootstrap 选项卡中调用特定的高级自定义字段中继器字段
【发布时间】:2014-07-03 14:28:43
【问题描述】:

我有一堆通过几个高级自定义字段重复字段加载的缩略图。单击缩略图时,我希望每个缩略图的相应文本出现在 Bootstrap 选项卡的内容 div 中。文本与图像在同一个重复器中,但在一个单独的字段中。但我不知道如何通过单击访问相应的转发器字段文本。缩略图的数量是无限的。

缩略图列表使用此代码:

<ul>
         <?php foreach (get_field('repeater-field', 39) as $row) :?>

             <li><a href="#profile" data-toggle="tab"> <img class="img-responsive img-rounded img-ref" src="<?php print $row['image'] ?>"/> </a>    </li>             
         <?php endforeach; ?>
         </ul>

这就是我迄今为止的标签内容,但它只会显示第一个重复字段,而不是每个相应缩略图的文本:

<div class="tab-content">
  <div class="tab-pane active" id="home"></div>
  <div class="tab-pane" id="profile">
  <?php

  $rows = get_field('repeater-field', 39);
  echo $rows[0]['text'];
  ?>


  </div>

</div>

【问题讨论】:

    标签: php wordpress repeater advanced-custom-fields


    【解决方案1】:

    设法自己解决了这个问题。但是由于某种原因,Bootstrap 淡入淡出效果消失了……

    用于缩略图:

             <ul class="tabs">
    
    
            <?php 
    
            $i = 1;
            while( have_rows('my_field', 39) ): the_row(); 
    
                // vars
                $image = get_sub_field('thumb');
    
    
    
                ?>
    
                <li class="tab-list">
    
                    <a href="#<?php echo $i; ?>" data-toggle="tab">
    
                        <img class="img-responsive img-rounded img-ref" src="<?php echo $image['url']; ?>" alt="<?php echo $image['alt'] ?>" />
    
    
                        </a>
    
    
    
                </li>
    
            <?php
            $i++;
            endwhile;
            ?>
    
    
            </ul>
    
           <?php endif; ?>
    

    这对于标签:

        <div class="tab-content">
        <div class="tab-pane fade in " id="home"></div>
    
        <?php 
    
        $i = 1;
        while( have_rows('my_field', 39) ): the_row(); 
    
            // vars
            $text = get_sub_field('my_text');
    
    
    
            ?>
    
    
            <div class="tab-pane fade" id="<?php echo $i; ?>">
    
    
    
                    <?php echo $text; ?>
    
    
    
    
    
    
            </div>
    
        <?php
        $i++;
        endwhile;
        ?>
    
    
        </div>
    
    <?php endif; ?>
    

    【讨论】:

      猜你喜欢
      • 1970-01-01
      • 1970-01-01
      • 2019-04-08
      • 2018-08-15
      • 2015-12-28
      • 2021-06-04
      • 2015-04-21
      • 2016-02-01
      • 1970-01-01
      相关资源
      最近更新 更多