입력 한 모든 ACF 리피터 필드 쌍 주위에 div를 추가해야합니다. 3 개 필드마다 작업을 수행하는 코드 스 니펫이 있습니다. 번호를 변경할 때마다 다음 div ID가 이전 ID의 하위 항목이됩니다. 제안 사항이 우수 할 것입니다. 감사합니다.2 리피터 필드마다 div 추가 ACF
// check if the repeater field has rows of data
if(have_rows('services')):
// loop through the rows of data
// add a counter
$count = 0;
$group = 0;
while (have_rows('services')) : the_row();
// vars
$teacher_bio = get_sub_field('service_title');
$teacher_name = get_sub_field('service_information');
$teacher_image = get_sub_field('icon');
if ($count % 3 == 0) {
$group++;
?>
<div id="services-<?php echo $group; ?>" class="cf group-<?php echo $group; ?>">
<?php
}
?>
<div class="service">
<img src="<?php the_sub_field('icon'); ?>" />
<p><?php echo $teacher_name; ?></p>
<?php echo $teacher_bio; ?>
</div><!-- .teacher -->
<?php
if ($count % 3 == 2) {
?>
</div><!-- #services -->
<?php
}
$count++;
endwhile;
else :
// no rows found
endif;
이 쉽게 수 없습니다를, 당신이 당신 중계기 내부에 중계기가 있다면? 그때 각 "선생님/서비스"에 대한 행이있을 것이고 당신은 당신이 원했던 어떤 html로 그것을 감쌀 수 있습니다 – Stender