.. _template_loops:
.. highlight:: jinja
#####################
Loops
#####################
.. _for_loop:
**********
For loop
**********
This will split a list of comma separated Custom Fields and loop through them.
.. code::
{% for key in "[post_custom_fields]"|split(',') %}
- {{ key|trim }}
{% endfor %}
You can also use Post Status Notifier's placeholders ending with **"_array"** (which are PHP arrays internally) to loop through them directly.
.. code::
{% for key in [post_custom_fields_array] %}
- {{ key|trim }}
{% endfor %}
Three column design
~~~~~~~~~~~~~~~~~~~
This is an example of how to split an array into three parts and show the values in three columns. It uses PSN's custom filter :ref:`filter_divide`.
.. code::
{% for part in [post_categories_array]|divide(3) %}
{% for column in part %}
- {{ column }}
{% endfor %}
{% endfor %}
.. note::
Check out the `Twig documentation page `_ for more details about the ``for`` loop.