Home Forums Add-ons Repeater Field ACF Multiple Checkboxes Output


ACF Multiple Checkboxes Output

  • I am trying to make FAQ’s section using ACF. FAQ’s will have categories which are checkboxes. I know how to output all FAQ’s but I don’t know how to output FAQ’s based on checkbox.

    Here’s the code

    <div class="grid-container">
    <div class="small-12 cell section_header"><h2 class="section_title text-center">Frequently Asked Questions</h2></div>
    <ul class="thin accordion faq" data-accordion data-allow-all-closed="true">
    <?php if ( have_rows( 'faq', 'option' ) ) : ?>
        <?php while ( have_rows( 'faq', 'option' ) ) : the_row(); ?>
                <li class="accordion-item" data-accordion-item>
                    <a href="#" class="accordion-title"><?php the_sub_field( 'faq_title' ); ?></a>
                    <div class="accordion-content" data-tab-content><?php the_sub_field( 'faq_answer' ); ?></div>
        <?php endwhile; ?>
    <?php else : ?>
    <?php endif; ?>
  • Hi @daxsm

    Thanks for the mail.

    Is the checkbox field part of the repeater sub_fields?

    I would recommend that you make use of the PHP in_array method to check if the value belongs to a category before displaying it.

    Hope this helps.

  • This reply has been marked as private.
  • Hi @daxsm

    Please share a JSON export in your next response so that I can try and reproduce this on my end.

Viewing 4 posts - 1 through 4 (of 4 total)

The topic ‘ACF Multiple Checkboxes Output’ is closed to new replies.