Add ordinal suffix to loop.index I'd like to add an ordinal suffix to the loop.index variable within a for loop.

For example:

1st
2nd
3rd
This can also be done with a Twig macro, rather than creating a plugin:

{% macro ordinal(number) %}
    {%- spaceless %}
    {% if ((number % 100) &gt;= 11) and ((number % 100) &lt;= 13) %}
        {{ number }}th
    {% else %}
        {% set ends = ['th','st','nd','rd','th','th','th','th','th','th'] %}
        {{ number ~ ends[number % 10] }}
    {% endif %}
    {% endspaceless -%}
{% endmacro %}

{% from _self import ordinal %}

{% for entry in craft.entries %}
    &lt;li&gt;{{ ordinal(loop.index) }}&lt;/li&gt;
{% endfor %}