Answer the question
In order to leave comments, you need to log in
How to display repeater in wordpress repeater?
I have such a field structure - there is a repeater, it has a repeater-in-repeater (another repeater) and a repeater-title. Further in the repeater-in-repeater, in fact, the repeater with the fields repeater-in-repeater-title, repeater-in-repeater-img, repeater-in-repeater-ul, repeater-in-repeater-price. This is how I output:
<?php if (have_rows('repeater')) : ?>
<?php while (have_rows('repeater')) : the_row();
// переменные
/* $rir = get_sub_field('repeater-in-repeater'); */
$title = get_sub_field('repeater-title');
?>
<h3><?php $title ?></h3>
<?php if (have_rows('repeater-in-repeater')) : ?>
<?php while (have_rows('repeater-in-repeater')) : the_row();
$rir_title = get_sub_field('repeater-in-repeater-title');
$rir_img = get_sub_field('repeater-in-repeater-img');
$rir_ul = get_sub_field('repeater-in-repeater_ul');
$rir_price = get_sub_field('repeater-in-repeater-price');
?>
<div class="catalog-flex">
<div class="catalog-flex__item">
<h3><?php $rir_title ?></h3>
<div class="catalog-flex__item__flex">
<div class="catalog-flex__item__flex__item"><a class="catalog-flex__item__flex__item__a" href="<?php echo $rir_img; ?>"><img src="<?php echo $rir_img['url']; ?>" alt="<?php echo $rir_img['alt'] ?>" /></a></div>
<div class="catalog-flex__item__flex__item">
<?php $rir_ul ?>
<div class="catalog-flex__item__flex__item__price"><?php $rir_price ?></div>
<div class="catalog-flex__item__flex__item__btn"><button class="modal-btn">Заказать</button></div>
</div>
</div>
<?php echo $content; ?>
</div>
</div>
<?php endwhile; ?>
<?php endif; ?>
<?php endwhile; ?>
<?php endif; ?>
Answer the question
In order to leave comments, you need to log in
$repeater = get_field('имя главного повторителя');
foreach( $repeater as $item ) {
// Если надо вывести поле из первого повторителя
echo $item['поле повторителя'];
// Повторитель внутри повторителя
foreach ( $item['имя повторителя в повторителе'] as $subitem ) {
echo $subitem['поле повторителя'];
}
}
Didn't find what you were looking for?
Ask your questionAsk a Question
731 491 924 answers to any question