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 🙂

    //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 class="faq_answer_container">
    					<div class="faq_answer">
    						<span><?php the_sub_field('faq_answer'); ?></span>
    	<?php endwhile; ?>
    <?php endif; ?>