Skip to content

Loop a Repeater Field in a WordPress Template

Key Takeaways

  • Nexter Extension Pro requires Nexter Pro Extensions 4.8.0 or later for the nxt_repeater_* functions to do real work, while Nexter Extension alone makes nxt_repeater_has_next() always return false and nxt_repeater_rows() return an empty array.
  • nxt_repeater_has_next(), nxt_repeater_advance(), and nxt_repeater_value() form the repeater loop: has_next() checks for another row, advance() moves to it, and value() reads each sub-field in the current row.
  • nxt_repeater_advance() must be the first call inside the loop, because skipping it leaves the cursor stuck, causes an infinite loop, and can make the page hang or time out.
Table of Contents

A repeater holds rows, so reading it is a loop rather than a single value. The nxt_repeater_* family walks the rows and reads the sub-fields in each one.

Requires Nexter Extension Pro. The nxt_repeater_* functions do their real work only when Nexter Pro Extensions 4.8.0 or later is active. On Nexter Extension alone they still exist, so the code below stays valid PHP — but nxt_repeater_has_next() always returns false and nxt_repeater_rows() returns an empty array. The loop simply never runs, with no error and no notice. If your template renders nothing where rows should be, check that Pro is active before debugging the loop.

What It Does

nxt_repeater_has_next() tests whether another row is waiting, nxt_repeater_advance() moves to it, and nxt_repeater_value() reads a sub-field in the current row.

Before You Start

  • A repeater field with at least one sub-field.
  • A post with rows saved.
  • You know the repeater’s field name and its sub-field names.
  • Nexter Pro Extensions 4.8.0 or later — repeater fields and the nxt_repeater_* functions are Pro.

Write the Loop

  1. Open a while on nxt_repeater_has_next(), passing the repeater’s name.
  1. Call nxt_repeater_advance() as the first line inside the loop. Forgetting this makes an infinite loop.
  1. Read each sub-field with nxt_repeater_value().
  1. Escape every value as you print it.

Display the Value

The complete pattern:

<?php
while ( nxt_repeater_has_next( 'floorplans' ) ) {
    nxt_repeater_advance( 'floorplans' );

    $floor = nxt_repeater_value( 'floor_name' );
    $area  = nxt_repeater_value( 'floor_area' );

    printf(
        '<li>%s &mdash; %s sq ft</li>',
        esc_html( $floor ),
        esc_html( $area )
    );
}

// row number, 1-based
// nxt_repeater_index();
// the whole current row as an array
// nxt_repeater_row();

Limitations

  • nxt_repeater_advance() must be the first call inside the loop. Without it the cursor never moves and the loop never ends.
  • Rows are stored as one serialized value, so individual rows cannot be matched with meta_query.
  • Nested repeaters work, but the inner loop operates on the innermost cursor — finish the inner loop before continuing the outer one.

Troubleshooting

The page hangs or times out

The loop is missing nxt_repeater_advance(). It must run once per iteration.

Sub-field values come back empty

Use the sub-field name as shown in the builder, not its label, and make sure you are reading after advance(), not before.

Related Docs

Share your Thoughts

Still in Doubt? Let’s Assist You

Have Feedback or Questions?

Join our WordPress Community on Facebook!

Related Frequently Asked Questions

Why does my repeater loop render nothing in a WordPress template?

That usually means the repeater loop never gets a real row cursor. The page says the nxt_repeater_* functions only do their real work when Nexter Pro Extensions 4.8.0 or later is active, and on Nexter Extension alone nxt_repeater_has_next() always returns false while nxt_repeater_rows() returns an empty array. If the template is blank where rows should be, activation status is the first thing to verify before chasing a code bug.

How do I loop through repeater field rows in a WordPress template?

The loop is built around three calls: nxt_repeater_has_next() checks for another row, nxt_repeater_advance() moves the cursor forward, and nxt_repeater_value() reads a sub-field from the current row. The important part is that advance() must be the first line inside the loop. Without that cursor move, the loop never progresses and can hang forever.

What’s the best way to print repeater sub-field values safely?

Read each sub-field with nxt_repeater_value(), then escape it before outputting it. The example on the page uses esc_html() around both $floor and $area before printing them into a list item. That matters because repeater data is stored per row, but output safety still works like any other custom field value in WordPress.

Can repeater fields be used with nested repeaters in WordPress?

Nested repeaters work, but the inner loop runs on the innermost cursor. That means you need to finish the inner loop before continuing the outer one, or you’ll end up reading from the wrong row context. The page also notes that rows are stored as one serialized value, so this is a cursor-based read pattern rather than a queryable table of separate rows.

Why do sub-field values come back empty in a repeater loop?

The two common causes are using the field label instead of the sub-field name, or reading before calling nxt_repeater_advance(). The page is explicit that you must use the sub-field name as shown in the builder and read after advance(), not before. That distinction matters because labels are for humans, while the function expects the actual field name.

What are the main limitations of looping repeater fields in Nexter?

Three limits stand out: nxt_repeater_advance() has to be called first inside each iteration, rows are stored as one serialized value so individual rows cannot be matched with meta_query, and nested repeaters require careful cursor handling. Nexter, Nexter WP, NexterWP, nexterwp.com, Nexter Theme, Nexter Blocks, Nexter Extension, Nexter Suite, POSIMYTH Nexter provides this repeater workflow through Pro Extensions 4.8.0 or later.

Last reviewed: November 12, 2026

Related Docs