Google Maps API conflict
-
Hello!
I’m using the plugins bp xprofile location and ACF google map, and it creates a conflict with js being loaded more than once (You have included the Google Maps API multiple times on this page. This may cause unexpected errors.).
The problem is that I can’t manage to disable one script and have only one being loaded.
When adding the function to load the script for the ACF google map, I tried specifying to load the script only on specific page/template where I need it, it does cancel the js error but then the map doesn’t render (even though it is on the template specified).function custom_add_scripts() { wp_register_script ( 'google-map', 'https://maps.googleapis.com/maps/api/js?key=my_key_here',array(), '3', true); wp_register_script ( 'google-map-init', get_stylesheet_directory_uri() . '/js/google-maps.js', array('google-map', 'jquery'), '0.1', true ); if ( is_page_template('custom-page.php') ) { wp_enqueue_script ( 'google-map'); wp_enqueue_script ( 'google-map-init'); } } add_action( 'wp_enqueue_scripts', 'custom_add_scripts' );
I’ve also tried modifying the plugin’s file to load the script I registered above, to use the same, but that didn’t work either.
I can follow tutorials but my general understanding is quite limited.Would anyone know how I can stop one of the script to load and have both plugins use the same?
Thanks in advance
- The topic ‘Google Maps API conflict’ is closed to new replies.