EACH Loop Tag

Provides easy looping through related entries (from relationship fields), taxonomies and media upload fields within Pods Templates.


The [each] tag is used for looping through relationship fields, taxonomy and media upload fields within your Pods Templates. When you’re inside the loop of the field or taxonomy or image, you can use magic tags for the fields within each of those objects.

Quick Start Guide

  • Start your [each] loop with the relationship field, taxonomy or image field: [each relationship_field], [each taxonomy] or [each image_field]
  • Inside the loop, use the magic tag of the fields inside the relationship, taxonomy or image field (ie post_title, permalink).
    NOTE: Do not repeat the relationship field, taxonomy or image field inside the loop or you’ll step out of the loop (ie Don’t use {@relationship_field.post_title}, it’s just {@post_title}.
  • End your loop with another [/each] tag.

EACH Block for Relationship Field

This example shows how to loop through all entries in a relationship field—in this case a multi-select relationship field called chapters in a custom post type book—adding markup to each entry:

<ul class="chapters-list">
[each chapters]
    <li><a href="{@permalink,esc_url}">{@post_title}</a></li>

This code would output one list item (<li>) with the post_title for each related chapter post.

NOTE: When you’re inside the [each field_name] block, you do not need to prefix your relationship based magic tags with the {@field_name}, like {@field_name.post_title}, just use {@post_title}. When you’re in a multiple select loop, the each is actually creating the loop, so prefixing the post_title or permalink with the field name in front of it inside the each loop will break you out of the loop. Many people run into this mistake when making each blocks.

You cannot use the Each Block to loop through a Simple Relationship Field (Predefined or Custom).

Each Block for Taxonomy

[each taxonomy-name]
<li><a href="{@permalink,esc_url}">{@name}</a></li>

Each Block for Images

If you’re created a multiple image field, you can also each through that connection to output a grid or gallery. Of course, if you activated the “Output as WordPress Gallery” you only have to type {@gallery}.

[each gallery_images]

Note that this uses the Special image handling Magic Tags. You could reasonably also do the following:
[each gallery_images]
<div><img src="{@_src.medium,esc_url}" class="gallery" /></div>

Limitations of the EACH Block

You cannot use the each loop to order in a specific way, or filter specific records or only show a specific number of records. each is designed to loop through everything on the other side of the loop, no ordering, no limiting, no filtering. If you need more control, you need to be using PHP Theme Templates.