Support

Account

Home Forums Add-ons Repeater Field Add number for each repeater row

Solved

Add number for each repeater row

  • Hi
    I’m sure this must have been answered before and is probably quite simple to do if you know how, but unfortunately I just don’t have the php skills and I haven’t found the answer on this forum.
    I am looking for a way to add a number to identify each row in a repeater.
    I would like to identify if it is row 1, 2 or 3 and have an if statement to display each differently.
    Can anyone please help me with this?
    Many thanks!

  • there is a function in acf to get the row index.

    
    if (have_rows('repeater')) {
      while (have_rows('repeater')) {
        the_row();
        $row_index = get_row_index();
        // do something different depending on value of row index
      }
    }
    
  • Perfect!
    Thank you so much – that’s just what I needed.

Viewing 3 posts - 1 through 3 (of 3 total)

You must be logged in to reply to this topic.

We use cookies to offer you a better browsing experience, analyze site traffic and personalize content. Read about how we use cookies and how you can control them in our Cookie Policy. If you continue to use this site, you consent to our use of cookies.