Example #1
0
function the_modules_loop($modules_field = 'modules')
{
    // Loop through rows of flexible content field
    while (the_flexible_field($modules_field)) {
        // Render module template based on the row layout's name
        $module_name = str_replace('_', '-', get_row_layout());
        the_module($module_name);
    }
}
Example #2
0
<!doctype html>
<html lang="en">
  <head>
    <meta charset="utf-8">
    <meta name="viewport" content="width=device-width, initial-scale=1">
    <?php 
wp_head();
?>
  </head>
  <body <?php 
body_class();
?>
>
  <?php 
while (have_posts()) {
    the_post();
    // Check if ACF is enabled and the modules field exists
    if (function_exists('get_field') && get_field('modules') !== null) {
        the_modules_loop();
    } else {
        the_module('post');
    }
}
?>
  <?php 
wp_footer();
?>
  </body>
</html>