似乎這個問題已經被引導了3次,但是,我無法找到任何可摺疊的card
s,更不用說它在PHP循環中實現了。手風琴一次打開一個面板使用摺疊
我正在通過高級自定義字段中繼器循環並將結果輸出到可摺疊的卡片中。
一切都運轉良好,除非我無法在另一張打開時讓手風琴關閉其他卡。一次只能打開一個。
<?php
// check if the repeater field has rows of data
if(have_rows('video_accordion')): ?>
<div id="accordion" class="col-sm-12" role="tablist" aria-multiselectable="false">
<?php $index = 0; ?>
<?php // loop through the rows of data
while (have_rows('video_accordion')) : the_row(); ?>
<div class="card">
<a data-toggle="collapse" class="<?php if($index != 0): echo 'collapsed'; else : endif; ?>" data-parent="#accordion" href="#collapse<?php echo $index; ?>" aria-expanded="false" aria-controls="collapse<?php echo $index; ?>">
<div class="card-header" role="tab" id="heading<?php echo $index; ?>">
<?php the_sub_field('video_title'); ?>
</div>
</a>
<div id="collapse<?php echo $index; ?>" class="collapse show <?php if($index == 0): echo 'in'; else : endif; ?>" role="tabpanel" aria-labelledby="heading<?php echo $index; ?>">
<div class="card-block">
<iframe src="https://player.vimeo.com/video/<?php the_sub_field('video_id'); ?>" width="640" height="288" frameborder="0" webkitallowfullscreen mozallowfullscreen allowfullscreen></iframe>
</div>
</div>
</div>
<?php $index ++ ?>
<?php endwhile; ?>
編輯的要求
<div id="accordion" class="col-sm-12" role="tablist" aria-multiselectable="false">
<div class="card">
<a data-toggle="collapse" class="" data-parent="#accordion" href="#collapse_1" aria-expanded="false" aria-controls="collapse">
<div class="card-header" role="tab" id="heading">
title 1
</div>
</a>
<div id="collapse_1" class="collapse show" role="tabpanel" aria-labelledby="heading">
<div class="card-block">
<iframe src="https://player.vimeo.com/video/203710832" width="640" height="288" frameborder="0" webkitallowfullscreen mozallowfullscreen allowfullscreen></iframe>
</div>
</div>
<div class="card">
<a data-toggle="collapse" class="" data-parent="#accordion" href="#collapse_2" aria-expanded="false" aria-controls="collapse">
<div class="card-header" role="tab" id="heading">
Title 2
</div>
</a>
<div id="collapse_2" class="collapse show" role="tabpanel" aria-labelledby="heading">
<div class="card-block">
<iframe src="https://player.vimeo.com/video/203710832" width="640" height="288" frameborder="0" webkitallowfullscreen mozallowfullscreen allowfullscreen></iframe>
</div>
</div>
</div>
</div> <!-- end of accordion -->
即使粘貼this example
HTML唯一的例子給出了相同的行爲。
非常感謝
從文檔粘貼的示例工作[如預期](http://www.codeply.com/go/55NW9qY7FN)。 – ZimSystem
什麼可能是錯誤的 - 檢查這個視頻了https://youtu.be/uXW58RuC0sw – Taylorsuk