Home › Forums › Add-ons › Repeater Field › setting up multiple Accordions with repeater field › Reply To: setting up multiple Accordions with repeater field
Hi @marc-k1205
You don’t need to put the whole thing in a function..
Remove the function wrapper 🙂
As a side note developer to developer you should really attempt to write readable code.. Look at this compared to the one you posted 🙂
<?php
//My ACF Fields for reference
//faqs - field group
//faq_question - sub-field
//faq_answer - sub-field
// check if the repeater field has rows of data
if( have_rows('faqs') ):
?>
<?php while ( have_rows('faqs') ) : the_row(); ?>
<div id="faq_container">
<div class="faq">
<div class="faq_question">
<span class="question"><?php the_sub_field('faq_question'); ?> </span>
<span class="accordion-button-icon fa fa-plus"></span>
</div>
<div class="faq_answer_container">
<div class="faq_answer">
<span><?php the_sub_field('faq_answer'); ?></span>
</div>
</div>
</div>
</div>
<?php endwhile; ?>
<?php endif; ?>
Welcome to the Advanced Custom Fields community forum.
Browse through ideas, snippets of code, questions and answers between fellow ACF users
Helping others is a great way to earn karma, gain badges and help ACF development!
We use cookies to offer you a better browsing experience, analyze site traffic and personalize content. Read about how we use cookies and how you can control them in our Privacy Policy. If you continue to use this site, you consent to our use of cookies.