Skip to content

Instantly share code, notes, and snippets.

Embed
What would you like to do?
getting a list of features from an ACF repeater and split it in 2 different balanced lists
<div class="solution-features-list">
<?php
$features = [];
if ( have_rows( 'features' ) ) :
while ( have_rows( 'features' ) ) : the_row();
array_push($features, get_sub_field( 'feature' ));
endwhile;
endif;
$twocols = array_chunk($features,ceil(count($features)/2));
?>
<div class="wrapper">
<div class="grid-x grid-padding-x">
<div class="cell large-6 solution-features-list__left">
<ul>
<?php foreach ($twocols[0] as $feature) : ?>
<li><?php echo $feature;?></li>
<?php endforeach;?>
</ul>
</div>
<div class="cell large-6 solution-features-list__right">
<ul>
<?php foreach ($twocols[1] as $feature) : ?>
<li><?php echo $feature;?></li>
<?php endforeach;?>
</ul>
</div>
</div>
</div>
</div>
<!-- END solution features -->
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
You can’t perform that action at this time.