Table of Contents

The Loop Object in PublishPress Authors

The PublishPress Authors Pro plugin allows you to create custom author layouts.

This article explains a key feature of the custom layouts: the loop.

authors is an iterator object containing the list of authors. You can use it for building the loop of authors:

{% for author in authors %}
    <span class="pp-multiple-authors-layout-{{layout}} author_index_{{ loop.index }}">
        <a href="{{ author.link }}" class="{{ item_class }}" rel="author">{{ author.display_name }}</a>{% if loop.index < authors|length %},{% endif %}
    </span>
{% endfor %}

You can use the instruction “for” and set the name of the variable that will receive the author instance on each iteration. Inside the loop you have a special variable loop.index which returns the index of the current iteration, but using it is optional.

Professional publishing plugins for WordPress! Get PublishPress