Adding Google Maps API key to code
-
I created a new map and it does not work because it needs a Google Maps API key.
I generated one and I wrote code to add it to the call to //maps.google.com/maps/api/js.
add_action('wp_footer', 'sm_add_gmaps_api_key', 1); function sm_add_gmaps_api_key() { wp_deregister_script('google-maps-api'); $gmaps_api_key = 'Insert Your API Key Here'; wp_register_script('google-maps-api', '//maps.google.com/maps/api/js?key='.$gmaps_api_key, false, null, true); }
I have a suggestion to allow users enter an API key without using a new options page: add a new parameter to the shortcode!
Viewing 1 replies (of 1 total)
Viewing 1 replies (of 1 total)
- The topic ‘Adding Google Maps API key to code’ is closed to new replies.