Code snippet to create regular ACF Google Map entry in DB from an ACF Repeater Google Map Sub Field
Project detail
I want to create a snippet which would take repeater field data from a Google Map subfield using the code like from the links below and then create new regular ACF Google Map fields with that looped through data.
Those now multiple extra Google Map fields would be hidden from the front end and only exist in the db to be available for query by mapping plugins.
Using this code for the looping:
“`
<div class="marker" data-lat="” data-lng=””>
“`
I don’t need the display part of it. I want that when repeater field data is entered into the Google Map sub field of the repeater field, it creates a new entry as a regular ACF Google Map field entry in the db.
Can anyone help?
I see these code examples for the looping part.
ACF Support said: You can use the get_field() function to retrieve the repeater data and use basic array operations to retrieve ‘lat’ and ‘lng’ from the location field instead of creating new fields. However, if your mapping solutions require separate ACF fields, I would recommend you take advantage of the acf/save_post callback to update the fields with the data contained in offset ‘lat’ and ‘lng’ from the location field.