Splitting a List of Entries Into Two Columns
Problem
You have a list of entries and want to split that into two columns in your markup.
Solution
{% for listItem in craft.entries.section('listItems').limit(null) %}
{% if loop.first %}
<div class="column">
<ul class="plain">
{% endif %}
<li>{{ listItem.title }}</li>
{# Divide the list by 2 and get the floor() integer for comparison, using the // operator. -1 puts the odd item in the lefthand list. #}
{% if (loop.length // 2) == (loop.index - 1) %}
</ul>
</div><!--
--><div class="column">
<ul class="plain">
{% endif %}
{% if loop.last %}
</ul>
</div>
{% endif %}
{% endfor %}
Submitted by Clearbold Doe on 1st February, 2017