Home Forums Add-ons Repeater Field Unique ID for repeater rows


Unique ID for repeater rows

    • Tudor

    • October 29, 2013 at 6:56 am


    I’m using a repeater to generate some text boxes (they have several sub-fields, for example title, subtitle, text, related link, etc). I want to then link each image in the media uploader to a unique text box and display both using a custom gallery code (the text box will appear this next to the image). I’m doing this to support more advanced cases than the media uploader description/caption/alt text could handle.

    I got this working, but the problem is that the IDs that ACF generates for the different rows in a repeater are not unique, and always start from 0 depending on the set order. You can see how this is a problem, because if I reorder the rows at a later point, the associations will get all mixed up.

    Is there any possible solution for this?

    Thanks for your help.

    • Tudor

    • October 29, 2013 at 8:02 am

    I did more digging and I think I might have made this work in a different way, by adding an Image subfield for each row and thus creating the relationship in the repeater, instead of the other way around.

    In the gallery code, I can the use get_field to get all the rows and for every images search for a row which has a linked image ID matching the current one.

    I’d still be curious to know if it could also be done the other way around.

    • Elliot

    • October 30, 2013 at 4:19 pm

    Hi @Tudor

    To add in a row ID, you could ad a text or number sub field to the repeater and write some CSS / JS which hides the column, and sets the value to a unique string / number.

    This means that each row will always have a unique ID


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.