Looper Item - Get a unique ID for each Looper Item

Hi there,

So I am building a dynamic menu for my posts, with anchors to the headlines in the post. The looper provider loops through an ACF Repeater field which is containing the headlines for the specific post.

In order to make the menu work, I need each looper item to have a unique id, so that I can create an anchor-link for that headline. At the moment, I am using the looper item index as anchor-value, but it doesn’t seem like the smartest way to make it work.

I know each custom field have a corresponding id field like “field_xxxx…”. How do I access that value for a looper item?

It would be best if the anchor could consist of the looper item value without spaces but I do not know how to do this in ACF - if even possible? E.g. the looper item value “Here is a headline” should be “here-is-a-headline” for the anchor-link.

I hope my question makes sense. Let me know what you think.

Thanks :slight_smile:

Hi Mathias,

Thanks for reaching out.
It is not very clear what you are trying to do here. But if you want to have a unique ID for each Looper Item you can concatenate the Looper Current Item Index and some text. As shown in the given example and screenshot.

id{{dc:looper:index}}

Screenshot-918-

NOTE: String manipulation is not possible with the Dynamic Content values.

Hope it helps.
Thanks

Hi Tristrup,

Thank you for your response. It makes sense with the id{{dc:looper:index}}, but that is a manual way of creating a unique id for the looper item.

I am looking for a way to automatically generate a unique id for each looper item from ACF.

Can you think of any?

An example would be that I could have the text value in the ACF field converted to a string without spaces, automatically. If the value of an item is “Here is a headline” the converted value would be “here-is-a-headline”.

Let me know what you think

Hi Mathias,

Regretfully, there is no such option available currently. As the string manipulation is not possible with the Dynamic Content values, the string can not be converted as you are expecting.

Thanks

This topic was automatically closed 10 days after the last reply. New replies are no longer allowed.