A loop is a {{#…}} block that repeats its markup once per entry. Inside the block, entry placeholders refer to the current entry:
{{#query:post count=3}}
<article><h3>{{title}}</h3><p>{{excerpt}}</p></article>
{{/query}}
Loop kinds
| Loop | Repeats over | Options |
|---|---|---|
{{#posts}} |
The entries of the current archive, blog, or search page. Templates only. | None |
{{#query:post_type}} |
Entries of one post type, anywhere. | count, paginate=1, orderby, order |
{{#taxonomy:taxonomy}} |
The terms of a taxonomy. | parent, orderby, order, include |
{{#terms:taxonomy}} |
The current entry’s terms in one taxonomy. | None |
{{#related}} |
Entries related to the current one. | count, orderby, order |
Loop items: define the card once
A loop item is a template that holds the markup for one row or card. Reference it by name instead of repeating markup in every loop:
{{#posts:post-card}}{{/posts}}
{{#query:doc:doc-card}}{{/query}}
The same card then serves the blog, search results, and related lists. Change the card template once and every list follows.
Inside a loop
{{loop_index}}, {{loop_total}}, {{is_first}}, {{is_last}}, and {{loop_separator}} are available for numbering, first and last styling, and separators.
Pagination
Add paginate=1 to a {{#query}} loop (archive loops paginate with the main query). Then place after the loop for Delta’s default controls, or compose your own from {{pagination_current}}, {{pagination_total}}, {{pagination_prev_url}}, and {{pagination_next_url}}.
One rule to remember
{{#posts}} works only in templates, where a main query exists. In a single page’s own Delta HTML, use {{#query:post_type}} instead. The agent knows this rule; if you see literal {{#posts}} text on a page, see Page is broken.