リピーターフィールドの件数を制御する方法です。
今回ではリピーターフィールドに投稿された内容を最大5件まで表示することができます
1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 |
<?php $i = 0; if(have_rows('repeater_field_name')): ?> <?php while(have_rows('repeater_field_name')): the_row(); $i++; ?> <?php if( $i < 6 ): ?> <span class="accordion_cont"><?php echo $i.'.'; ?><?php the_sub_field('sub_field_name'); ?></span> <div class="accordion_box"> <ul><?php while(have_rows('repeater_field_name')): the_row(); ?> <li><a href="#" class="accordion02"><?php the_sub_field('sub_field_name'); ?></a></li> <?php endwhile; ?> </ul> </div> <?php endif; ?> <?php endwhile; ?> <?php endif; ?> |
コメント