Find Jobs
Hire Freelancers

Code snippet to create regular ACF Google Map entry in DB from an ACF Repeater Google Map Sub Field

$10-30 USD

Imefungwa
Imechapishwa over 2 years ago

$10-30 USD

Kulipwa wakati wa kufikishwa
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: ``` <?php if( have_rows('locations') ): ?> <div class="acf-map" data-zoom="16"> <?php while ( have_rows('locations') ) : the_row(); // Load sub field values. $location = get_sub_field('location'); $title = get_sub_field('description'); $description = get_sub_field('description'); ?> <div class="marker" data-lat="<?php echo esc_attr($location['lat']); ?>" data-lng="<?php echo esc_attr($location['lng']); ?>"> <h3><?php echo esc_html( $title ); ?></h3> <p><em><?php echo esc_html( $location['address'] ); ?></em></p> <p><?php echo esc_html( $description ); ?></p> </div> <?php endwhile; ?> </div> <?php endif; ?> ``` 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. [login to view URL] [login to view URL] 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.
Kitambulisho cha mradi: 31968186

Kuhusu mradi

3 mapendekezo
Mradi wa mbali
Inatumika 2 yrs ago

Unatafuta kupata pesa?

Faida za kutoa zabuni kwenye Freelancer

Weka bajeti yako na muda uliopangwa
Pata malipo kwa kazi yako
Eleza pendekezo lako
Ni bure kujiandikisha na kutoa zabuni kwa kazi
3 wafanyakazi huru wana zabuni kwa wastani $29 USD kwa kazi hii
Picha ya Mtumiaji
Hello, I am wordpress developer working for local company in Serbia. We are working only on wordpress projects and I am serving about 20 clients from all over the world. Now I have time to work on something out of the company. I am definitelly sure I can do whatever you need in wordpress but I am not sure I understand this task completely, specially the part about maping plugins which are going to use those fields. That is very important part because I need to know what those plugins expect to find in the database. The rest is easy. I can hook on acf/save_post event and pick up all the fields from that post ( location field ) and save whatever is needed inside wp_postmeta table. Let me know if you are interasted in cooperation. Thanks
$56 USD ndani ya siku 7
5.0 (3 hakiki)
2.7
2.7
Picha ya Mtumiaji
Hello ! I am an expert Frontend developer. I am experienced in such as WordPress, Google Maps API, PHP, JavaScript and MySQL. I can start right away and want to discuss in detail. Please contact me to discuss more about this project. Thanks
$20 USD ndani ya siku 1
0.0 (0 hakiki)
0.0
0.0

Kuhusu mteja

Bedera ya UNITED STATES
Forest Ranch, United States
0.0
0
Njia ya malipo imethibitishwa
Mwanachama tangu Ago 18, 2021

Uthibitishaji wa Mteja

Asante! Tumekutumia kiungo cha kudai mkopo wako bila malipo kwa barua pepe.
Hitilafu fulani imetokea wakati wa kutuma barua pepe yako. Tafadhali jaribu tena.
Watumiaji Waliosajiliwa Jumla ya Kazi Zilizochapishwa
Freelancer ® is a registered Trademark of Freelancer Technology Pty Limited (ACN 142 189 759)
Copyright © 2024 Freelancer Technology Pty Limited (ACN 142 189 759)
Onyesho la kukagua linapakia
Ruhusa imetolewa kwa Uwekaji wa Kijiografia.
Muda wako wa kuingia umeisha na umetoka nje. Tafadhali ingia tena.