Skip to main content

Loop

{% for %}Repeats inner blocks for each item in a data source.

What it does​

The Loop block repeats its inner blocks once for each item in a data source — posts, pages, categories, users, or any custom data. Whatever blocks you place inside the Loop will render once per item.

How to use it​

  1. Add a Loop block
  2. Set a query name to expose query metadata (e.g. for pagination)
  3. Set a data alias — the variable name to access the current item (e.g. post, product)
  4. Select a query type (post, term, user, or item) and enter the query arguments
  5. For a post loop in an archive or index template, turn on Inherit Query to use the page's main query instead

The Loop block generates the query for you.

Build it visually

You don't have to write query arguments by hand. The Query Builder sets them up field by field, and the visual and code views stay in sync.

A Loop block: a post loop rendered on the canvas, beside its sidebar showing the query name, data alias, query type, and the visual query builder.

In the HTML inspector, the Loop shows as a {% for %} tag; the query arguments stay in the sidebar:

{% for post in get_posts() %}

You don't need to write this yourself — the block interface handles it. See the Loop overview for the full syntax, data sources, nested loops, and examples.

Next steps​