I m using ACF, where I have a group.

Inside that group I have a repeater.

All works fine until:

I add a group inside that repeat.

I don't manage to call the field from that group inside the repeater . .. any help will be super !

I'm using the below:

<section class="questions">
    <header class="section-header">
        <h1 class="beta center up-c" data-mobile-font-size="delta"><?php echo $questions['heading'] ?></h1>
    <form id="questions-form">

        <div class="questions-slider">
            <?php $i = 1 ?>
            <?php foreach($questions['items'] as $question): ?>
                <div class="slide">
                        <div class="image-container" style="background-image: url(<?php echo $question['image']['url']; ?>)">
                            <img src="<?php echo $question['image']['url']; ?>" alt="<?php echo $question['image']['alt']; ?>" />
                            <h1 class="beta up-c" data-mobile-font-size="delta"><?php echo $question['question'] ?></h1>
                        <div class="flexbox-container padding">

                            <input id="<?php echo 'q' . $i . 'a1' ?>" type="radio" name="<?php echo 'q' . $i ?>" value="1">
                            <label for="<?php echo 'q' . $i . 'a1' ?>">
                            <?php echo $question['answer-one'] ?></label>
                            <input id="<?php echo 'q' . $i . 'a2' ?>" type="radio" name="<?php echo 'q' . $i ?>" value="2">
                            <label for="<?php echo 'q' . $i . 'a2' ?>"><?php echo $question['answer-two'] ?></label>
                            <input id="<?php echo 'q' . $i . 'a3' ?>" type="radio" name="<?php echo 'q' . $i ?>" value="3">
                            <label for="<?php echo 'q' . $i . 'a3' ?>"><?php echo $question['answer-three'] ?></label>


// vars
$answer = get_field('answer_one');  

 if( $answer ): ?>
    <?php echo $answer['new_answer_one']; ?>
 <?php endif; ?>

                    <div class="question_note">
                                <p class="note_title" data-mobile-font-size="delta"><?php echo $question['note_title'] ?></p>
                                <p class="note_body" data-mobile-font-size="delta"><?php echo $question['note_body'] ?></p>
                                <a class="button button-primary next">Next Question</a>




                <?php $i++ ?>

            <?php endforeach; ?>

$questions is the main group

items the repeater

answer that new group...

Thkx so much !


You code looks very confusing. Why are you using the 'foreach'?

If you follow the ACF documentation, you just need to use:

if( have_rows('questions') ):
while( have_rows('questions') ): the_row();
// vars
$repeater-item = get_sub_field('repeater-item');
<div class="content">
<?php the_sub_field('caption'); ?>

For the group. Source: https://www.advancedcustomfields.com/resources/group/

And you only have to use:

if( have_rows('item') ):
while ( have_rows('item') ) : the_row();
else :
// no rows found

For the item. Source: https://www.advancedcustomfields.com/resources/repeater/

If you are using a variable called 'questions', where is that variable created and what info is it receiving?

Are you using 'sub_field' or just 'field' in the code?

At least with the info you gave, your code looks completely wrong to me.

Not the answer you're looking for? Browse other questions tagged or ask your own question.