Support

Account

Home Forums Front-end Issues Modularise flexible content with one template file per layout Reply To: Modularise flexible content with one template file per layout

  • Yes, use get_template_part(),

    example:

    Create a flex field with 2 layouts named “layout1” and “layout2”.

    Create a folder in your theme named “layouts” …wp-content/themes/your-theme/layouts

    In this folder create 2 files layout-layout1.php and layout-layout2.php

    
    if (have_rows('flex_field')) {
      while (have_rows('flex_field')) {
        the_row();
        get_template_part('layouts/layout', get_row_layout());
      }
    }