Support

Account

Home Forums Add-ons Flexible Content Field using a layout twice Reply To: using a layout twice

  • I can’t say where you’re code is going wrong. You can have any number of layouts and you could repeat the same layout 20 times if you wanted to and each one would have it’s own row.

    The only thing that might upset this is that if the current “Post ID” or the current “Row” is somehow being altered by the code in your template part. This could happen if you are calling wp_reset_postdata() in your template part and it is not working as you expect it to work.

    I also don’t really understand the whole if (file_exists).... part of your code.
    the WP function get_template_part() includes all of those checks and only loads the file if it exists.

    
    if (have_rows('sections')) {
      while (have_rows('sections')) {
        the_row();
        get_template_part('template-parts/blocks/'.get_row_layout());
      }
    }