Skip to content

Instantly share code, notes, and snippets.

Show Gist options
  • Save LiamBailey/80421d5dfb03345181950dc9482ec393 to your computer and use it in GitHub Desktop.
Save LiamBailey/80421d5dfb03345181950dc9482ec393 to your computer and use it in GitHub Desktop.
3 Column Logic
<div id="stat-wrapper">
<?php if ( have_rows( 'stats' ) ) : ?>
<?php $showitems = 2; $i = 0;$maincount = 0; ?>
<div class="col">
<?php while ( have_rows( 'stats' ) ) : the_row(); ?>
<div class="stat stat-<?php echo $maincount; ?>">
<?php if ( get_sub_field( 'stat_icon' ) ) { ?>
<img src="<?php the_sub_field( 'stat_icon' ); ?>" />
<?php } ?>
<?php the_sub_field( 'stat_headline' ); ?>
<?php the_sub_field( 'stat_copy' ); ?>
</div>
<?php $i++;$maincount++; ?>
<?php if ($i == $showitems && $maincount < 5) {
$showitems = $showitems == 2 ? 1 : 2;
?></div><!-- end .col //--><div class="col"><?php
$i = 0;
}
endwhile; ?>
</div><!-- End .col //-->
<?php else : ?>
<?php // no rows found ?>
<?php endif; ?>
</div>
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment