$collection->chunk($size)

Creates chunks of the same size and returns them in a new collection

  • since: Kirby 2.3.2
  • $size (int)
    Number of items per chunk
  • return ($collection)

Example:

<?php $chunks = page('projects')->children()->chunk(4); ?>
<?php foreach($chunks as $items): ?>
  <div class="row">
    <?php foreach($items as $item): ?>
    <article><?php echo $item->title() ?></article>
    <?php endforeach; ?>
  </ul>
<?php endforeach ?>