Support

Account

Home Forums Add-ons Flexible Content Field Flexible content wrong order Reply To: Flexible content wrong order

  • There are in the order that you’re code says they should be, you’re looping through and first showing all the text layouts, then the images and then the videos. If you want to show them in order then all of your if statements need to be inside a single loop.

    
    <?php 
      if (have_rows('post_content')) {
        while (have_rows('post_content')) {
          ?>
            <div>
              <?php 
                the_row();
                $layout = get_row_layout();
                if ($layout == 'layout_text') {
                  // code to show text content
                } elseif ($layout == 'layout_image') {
                  // code to show image content
                } elseif ($layout == 'layout_video') {
                  // code to show video content
                } else {
                  // code to do something else
                }
              ?>
            </div>
          <?php 
        } // end while
      } // end if have_rows
    ?>