Skip to content

Instantly share code, notes, and snippets.

@fcgist
Created September 12, 2016 12:38
Show Gist options
  • Star 0 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save fcgist/8d27e3efe45ba28aea3bc971dedd3692 to your computer and use it in GitHub Desktop.
Save fcgist/8d27e3efe45ba28aea3bc971dedd3692 to your computer and use it in GitHub Desktop.
Set the center location on Google map using ACF plugin
add_filter('wpgmp_maps_options','wpgmp_maps_options',1,2);
function wpgmp_maps_options($default,$map_id) {
global $post;
$acf_location = get_post_meta($post->ID,'location');
if(is_array($acf_location)) {
$default['center_lat']= $acf_location[0]['lat'];
$default['center_lng']= $acf_location[0]['lng'];
}
return $default;
}
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment