Home Forums Add-ons Options Page Extract data from options page (repeater field)


Extract data from options page (repeater field)

  • Hi, I’m using flexible content with the repeater field for creating a FAQ section. Everything works fine and is displayed on the page edit page.

    I have created an options page and now I need to show the group of fields inside it. To extract the data inside the page (front end) I followed this guide:
    Below is the code I have developed.

    but without success. How can I solve?
    Thank you

    // check if the flexible content field has rows of data
    if( have_rows('questions_frequent_flexible','option') ):
      // loop through the rows of data
      while ( have_rows('questions_frequent_flexible','option') ) : the_row();
          if( get_row_layout() == 'section_faq' ):
            if( have_rows('list_faq_repeater') ):
              while( have_rows('list_faq_repeater') ): the_row();
                $section_faq_question = get_sub_field('question_repeater');
                $section_faq_answear = get_sub_field('answear_repeater');
                  <div class="accordion-item">
                    <h2 class="accordion-header" id="heading<?php echo $n_question; ?>">
                      <button type="button" class="accordion-button collapsed text-left" data-bs-toggle="collapse" data-bs-target="#collapse<?php echo $n_question; ?>">
                        <?php echo $n_question; ?>. <?php echo $section_faq_question;?>
                    <div id="collapse<?php echo $n_question; ?>" class="accordion-collapse collapse text-left" data-bs-parent="#myAccordion">
                      <div class="card-body">
                          <?php echo $section_faq_answear;?>
                  <?php endwhile; ?>
              <?php endif; ?>
               <?php endif;
    else :
      // no layouts found
  • on everything you need the second parameter , ‘option’ if its an option field

  • Given your code I don’t see any reason it should not be working.

    What happens if you replace

    // no layouts found


    echo 'no layouts found';
Viewing 3 posts - 1 through 3 (of 3 total)

You must be logged in to reply to this topic.