Repeater
Class.
Renders the inner blocks of a block once per item: a post, a term, a comment, a user or a row of a table, like
core/post-template does for posts. A block receives it as parameter of render() instead of string $content;
which items there are, the block decides, e.g. with a query.
Each item gives the inner blocks the block context of the WordPress loop blocks – postId and postType,
termId and taxonomy, commentId –, or userId for a user and {namespace}/{table} for a row; blocks of the
theme or plugin read the item with #[Item], core blocks such as core/post-title with their own context. The
context of the ancestors stays available. For a post, the global post is set while its item renders.
In renders for the block editor the items are empty: the editor shows the inner blocks of the first item, or the one clicked, to edit, and the others as previews.
Methods
comment()
The inner blocks for a comment, with the context commentId.
Returns RepeaterItem
Throws InvalidArgumentException: If the comment does not exist.
post()
The inner blocks for a post, with the context postId and postType and the post as global post.
Returns RepeaterItem
Throws InvalidArgumentException: If the post does not exist.
row()
The inner blocks for a row of a table of a theme or plugin, with the context {namespace}/{table} (the
primary key).
Returns RepeaterItem
Throws InvalidArgumentException: If the row has not been saved yet.
term()
The inner blocks for a term, with the context termId and taxonomy.
Returns RepeaterItem
Throws InvalidArgumentException: If the term does not exist.
user()
The inner blocks for a user, with the context userId.
Returns RepeaterItem
Throws InvalidArgumentException: If the user does not exist.