Loop child entries (comments, variants, line items) that belong to a parent entry using of 'parent'.current or of 'parent'.'slug'.
In short: Sub-collections are configured on the parent collection in admin. On a detail page, list children with {for each entry in 'comments' of 'blog'.current ordered by newest}. Do not invent sub_entries helpers. Content model guide: Sub-Collections.
Video (follow-along): optional — comments loop on detail (
of 'blog'.current)
Beginner
Comments on a blog post
Detail page already resolves the post from the URL:
<h1>{title}</h1>
<div>{'content'}</div>
<section class="comments">
<h2>Comments</h2>
{for each entry in 'comments' of 'blog'.current ordered by newest}
<article>
<strong>{'author'}</strong>
<p>{'content'}</p>
</article>
{endfor}
</section>
Explicit parent slug
{for each entry in 'comments' of 'blog'.'hello-world' ordered by newest}
…
{endfor}
Use slug or id, not the human title.
Nested under a list (less common)
{for each entry in 'blog' with status = published ordered by newest}
<h2>{title}</h2>
{for each entry in 'comments'}
<p>{'author'}: {'content'}</p>
{endfor}
{endfor}
Prefer .current on detail pages for clarity and correct parent scope.
Product variants
{for each entry in 'variants' of 'products'.current ordered by order}
<h3>{title}</h3>
{endfor}
See Storefront patterns.
Public comment forms
Visitor-submitted sub-entries use /api/public_sub_entry.php (not {entry for} on the parent). See Public forms templating and the integration Public forms page.
Advanced Users
For developers & AI
Grammar
{for each entry in '<sub>' of '<parent>'.<slug|id|current|newest> [with …] [ordered by …] [limit N]}
Newest parent
{for newest entry in 'comments' of 'blog'.newest}
{for each entry in 'comments' of 'blog'.newest ordered by newest}
Model checklist
- Sub-collection defined on parent (
read_collection). - Field slugs match template
{'author'}etc. entry_method/auto_publishset if public submission.- Detail page has URL context before
.currentis meaningful.
Phantoms
| Wrong | Right |
|---|---|
{for each variant in sub_entries variants} | of 'products'.current |
| Parent title as identifier | slug or id |