Skip to content

Instantly share code, notes, and snippets.

@fcgist
Created September 8, 2016 04:55
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/260b3269d2d088a640658f170b87e15a to your computer and use it in GitHub Desktop.
Save fcgist/260b3269d2d088a640658f170b87e15a to your computer and use it in GitHub Desktop.
Center a Google Map on the Current WordPress Post
add_filter('wpgmp_maps_options','wpgmp_maps_options',1,2);
function wpgmp_maps_options($default,$map_id) {
// Declare global $post to get current post data.
global $post;
// Get current post's latitude added by wp google map pro meta box.
$default[center_lat]= get_post_meta($post->ID,'_wpgmp_metabox_latitude');
// Get current post's longitude added by wp google map pro meta box.
$default[center_lng]=get_post_meta($post->ID,'_wpgmp_metabox_longitude');
//Return modified center location of the map.
return $default;
}
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment