我有一堆缩略图,通过几个高级自定义字段重复字段加载。当单击缩略图,我希望各自的文本到每个缩略图出现在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>
这是我目前为标签设置的内容但它只会显示第一个repeater字段而不会显示每个缩略图的文本:
<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>
总算自己解决了。但是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; ?>