
Hi All,
Really hope someone can help
I’ve setup a Repeater and a Nested Repeater
Repeater = FAQs
This consists of:
– Category (text field)
– Q&A (repeater)
The Q&A repeater then has:
– Question (text field)
– Answer (Text Area)
The idea is to then bunch all questions by category type. I’m then using some jquery etc to make it more engaging but that’s an aside!
What I can’t seem to do is pass the value of category into the nested repeater like
Here’s my code but I can’t see what I’m dong wrong? Any help is appreciated:
<?php if(get_field('faqs')): while(has_sub_field('faqs')): ?>
<?php $variable = get_sub_field('category'); ?>
<?php if(get_sub_field('qa')): while(has_sub_field('qa')): ?>
<?php $variable = get_sub_field('category'); echo $variable; ?>
<article class="envor-sorting-item <?php the_sub_field('category'); ?>">
<header><?php the_sub_field('question'); ?> <i class="fa fa-plus"></i></header>
<p><?php the_sub_field('answer'); ?></p>
</article>
<?php endwhile; endif; ?>
<?php endwhile; endif; ?>
Solved it with this:
<?php if(get_field('faqs')): while(has_sub_field('faqs')):
$variable = get_sub_field('category');
if(get_sub_field('qa')): while(has_sub_field('qa')): ?>
<article class="envor-sorting-item <?php echo $variable; ?>">
<header><?php the_sub_field('question'); ?> <i class="fa fa-plus"></i></header>
<?php the_sub_field('answer'); ?>
</article>
<?php endwhile; endif;
endwhile; endif; ?>
Not sure what I was doing wrong before!! Hopefully it helps someone else