Created
January 22, 2016 01:21
-
-
Save kevinwhoffman/be490f77ce0f47804f14 to your computer and use it in GitHub Desktop.
Split ACF Google Map Field Data Into Separate Custom Fields
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
<?php | |
/** | |
* In order for Google Maps Builder Pro to work with ACF map fields, | |
* lat and lng are saved as separate fields in the function below. | |
*/ | |
function acf_save_lat_lng( $post_id ) { | |
// get value of ACF map field | |
$value = get_field( 'cel_map' ); | |
// update lat and lng as separate custom fields | |
update_post_meta( $post_id, 'cel_lat', $value['lat'] ); | |
update_post_meta( $post_id, 'cel_lng', $value['lng'] ); | |
} | |
// run after ACF saves the $_POST['acf'] data | |
add_action('acf/save_post', 'acf_save_lat_lng', 20); |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment