Skip to content

Instantly share code, notes, and snippets.

@dannydickson
Created April 29, 2021 23:08
Show Gist options
  • Star 0 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save dannydickson/db790a2142a2f3131added5df6691728 to your computer and use it in GitHub Desktop.
Save dannydickson/db790a2142a2f3131added5df6691728 to your computer and use it in GitHub Desktop.
If we have ACF flexible content rows setup on the page, display those. Otherwise, display the standard content.
<?php
// If have flexible content rows
if (have_rows('layouts')) :
while (have_rows('layouts')) : the_row();
$class = 'container';
if (get_sub_field('background_color')) {
$class .= ' ' . get_sub_field('background_color');
}
if (get_sub_field('background_pattern')) {
$class .= ' ' . get_sub_field('background_pattern');
}
?>
<div class="<?php echo $class; ?>">
<?php
if (have_rows('content')) :
// loop through the rows of data
while (have_rows('content')) : the_row();
get_template_part('template-parts/flex', get_row_layout());
endwhile;
else :
?>
<?php // if no flexible content rows, display standard content ?>
<div class="container">
<div class="layout">
<div class="column">
<?php the_content(); ?>
</div>
</div>
</div>
<?php
endif;
?>
</div>
<?php
endwhile;
endif;
?>
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment