Loop

The Loop tag gets items of site content by type, and repeats a template for each item.

Example

<Loop type=post count=3>
  <Field title />
</Loop>

In this example, the loop type is post.

The count attribute limits the number of items.

For each item in the loop, the template will display the title field of the item.

Concepts

  • Loop type is the name of the type of content items to get.

    It is usually in singular form, for example: post, page, or user. The name must be lowercase letters, and can contain numbers, - (dash) or _ (underscore).

  • Loop query means how to search, filter, and sort items.

    This is achieved by passing attributes, also called query parameters, to the Loop tag.

  • A field is a detail of the current item in the loop, such as title, author, and published date.

    The Field tag is used for this purpose.

  • There are ways to show or skip content based on conditions.

    This is done with the If tag, usually by checking an item's field values.

Loop types

The type attribute defines the loop type, usually corresponding to a post type.

Each loop type has a set of available query parameters and fields.

Core content

Field loop

These loop through a field value that is a list or map (associative array).

  • Field - field
  • User field - user_field

Abstract data

These loop through data created by List and Map tags, or passed directly as attribute value.

  • List - list
  • Map - map - Loop of a single item, which is a map
  • Map keys - map_keys - Loop of all keys in a map

Integrations

There are loop types that integrate with content from other plugins.

Loop features

Here are some other features of the loop.


Next: Field