Advanced Custom Fields

Repeaters And Nested Fields

Repeater fields and array-like ACF values use collection loop syntax.

Basic Repeater#

php
{{ team_members }}  <article>    <h3>{{ name }}</h3>    <p>{{ role }}</p>  </article>{{ else }}  <p>No team members yet.</p>{{ /team_members }}

Inside the loop, row values come from the current repeater row.

Aliases#

Name the current row when you want explicit paths:

php
{{ team_members as member, count }}  <article>    <h3>{{ count }}. {{ member.name }}</h3>    <p>{{ member.role }}</p>  </article>{{ /team_members }}

Use count for a one-based number. Use index for a zero-based number.

Parent Context#

Use parent to read from the outer post or row:

php
{{ team_members }}  <h3>{{ name }}</h3>  <p>Page: {{ parent.title }}</p>{{ /team_members }}

For deeper nesting, keep adding parent:

php
{{ sections }}  {{ cards }}    <h3>{{ title }}</h3>    <p>Section title: {{ parent.title }}</p>    <p>Page title: {{ parent.parent.title }}</p>  {{ /cards }}{{ /sections }}

Nested Collections#

Nested repeaters, galleries, and array-like fields work the same way:

php
{{ sections }}  <section>    <h2>{{ title }}</h2>    {{ links }}      <a href="{{ url }}">{{ label }}</a>    {{ /links }}  </section>{{ /sections }}