Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- // http://support.advancedcustomfields.com/forums/topic/acf-and-geo-mashup-integration/
- // http://wpquestions.com/question/showLoggedIn/id/10778
- // How to combine multiple locations onto one Google map using ACF and Geo Mashups
- //
- // This is how you integrate ACF’s Google Maps field with Geo Mashup.
- add_action('save_post', 'wpq_acf_gmap');
- function wpq_acf_gmap($post_id) {
- if(defined('DOING_AUTOSAVE') && DOING_AUTOSAVE) return $post_id;
- if( !isset($_POST['acf_nonce'], $_POST['fields']) || !wp_verify_nonce($_POST['acf_nonce'], 'input') ) return $post_id;
- if(get_post_status( $post_id ) <> 'publish' ) return $post_id;
- $location = (array) ( maybe_unserialize(get_post_meta($post_id, 'location', true)) ); //change location as your acf field name
- if( count($location) >= 3 ) {
- $geo_address = $location['address'];
- $geo_latitude = $location['lat'];
- $geo_longitude = $location['lng'];
- $geo_location = ''.$geo_latitude.','.$geo_longitude.'';
- update_post_meta( $post_id, 'geo_address', $geo_address );
- update_post_meta( $post_id, 'geo_latitude', $geo_latitude );
- update_post_meta( $post_id, 'geo_longitude', $geo_longitude );
- update_post_meta( $post_id, 'geo_location', $geo_location );
- }
- }
Add Comment
Please, Sign In to add comment