Plugin Author
Stiofan
(@stiofansisland)
Hi Deby,
The author of the theme is adding the maps api call the wrong way, usually i would tell you to contact the author to resolve this but i spotted a version of the theme on github, so if it has not changed then this code snipped should fix it (not tested)
// remove the current wrong maps api
remove_action( 'woo_head', 'woo_google_maps', 10 );
// add the maps the propper way
add_action( 'wp_enqueue_scripts', '_maps_api_the_right_way' );
function _maps_api_the_right_way() {
if ( is_page_template( 'template-contact.php' ) ) {
wp_enqueue_script( 'google-maps', 'https://maps.google.com/maps/api/js?', array(), null, false );
}
}
You can add a plugin called “code snippets” and add that bit of code and then check. Let us know how you get on.
Thanks,
Stiofan
Thank you for your reply. I did what you asked, installed the code snippets plugin and added the code above, but the map still gives an error.
Console said “You have included the Google Maps API multiple times on this page. This may cause unexpected errors.” So I deactivated the API KEY for Google Maps, thinking that would sort it out.
So now I just have the code snippet active, but am still getting these errors:
“You have included the Google Maps API multiple times on this page. This may cause unexpected errors.
hh @ js:101
js:35 Google Maps API error: MissingKeyMapError https://developers.google.com/maps/documentation/javascript/error-messages#missing-key-map-error”
I don’t understand how it says I have the key multiple times in the first error and then says the key is missing in the second error.
It’s so weird that the exact same theme on the other site works just fine here with no code/plugin etc at all.
Working example – http://www.gloriousbags.com/contact/
Non-working example – http://sewstylishbags.com/contact-us/
I did reach out to the developer Woo Commerce but they don’t offer support on free themes. You can’t even pay for support.
Any more ideas? Thanks so much.
Plugin Author
Stiofan
(@stiofansisland)
Hi Deby,
As i said, i did not test it, i think the remove action might be fired to early, try this instead:
// add the maps the propper way
add_action( 'wp_enqueue_scripts', '_maps_api_the_right_way' );
function _maps_api_the_right_way() {
// remove the current wrong maps api
remove_action( 'woo_head', 'woo_google_maps', 10 );
if ( is_page_template( 'template-contact.php' ) ) {
wp_enqueue_script( 'google-maps', 'https://maps.google.com/maps/api/js?', array(), null, false );
}
}
You will still need to us the API KEY for Google Maps plugin which it does not look like you are there.
The reason it work on one of your sites and not the other is that Google has given sites that used maps before the API key requirement some time to fix it before they will break it, eventually it will break like the other one so you should fix it there too.
Thanks,
Stiofan
Nope, still not working even with your plugin and the revised code snippet.
I think it’s time to give up and call it a day.
Frustrating when using free themes but I suppose you get what you pay for!
Thank you SO Much for trying to help.
Plugin Author
Stiofan
(@stiofansisland)
Hi Deby,
If it was me i would SHOUT at woo, they are still distributing a theme that will no longer work with the Google Maps API requirement, and infact they are not adding the JS file the WP way, it would take them 30 seconds to fix in the theme files.
Stiofan