Home › Forums › Backend Issues (wp-admin) › Google Maps field needs setting to add API key › Reply To: Google Maps field needs setting to add API key
@gab1982 the temporary fix is only intended for the WordPress backend because I suppose everyone has his own way of implementing the Google Map in the frontend.
If you used the embed code mentioned on the official ACF Google Maps page (https://www.advancedcustomfields.com/resources/google-map/), you just have to change the script-tag:
<script src="https://maps.googleapis.com/maps/api/js?v=3.exp&sensor=false"></script>
becomes
<script src="https://maps.googleapis.com/maps/api/js?v=3.exp&key=XXX"></script>
XXX being your own Google API key
A better option to include the JS-file in your frontend is by registering & enqueueing the script, you can do this by placing the following code inside your functions.php file, or have a look at a specific tutorial like https://premium.wpmudev.org/blog/adding-scripts-and-styles-wordpress-enqueueing/ (just the first that came up in Google search, I have nothing to do with wpmudev)
/**
* enqueue scripts and styles
*
*/
function nr_load_scripts() {
wp_register_script('googlemaps', 'https://maps.googleapis.com/maps/api/js?key=XXX',null,null,true);
wp_enqueue_script('googlemaps');
}
add_action( 'wp_enqueue_scripts', 'nr_load_scripts' );
– again, replace XXX with your own Google API key
– change the true to false if you want to load the script in de header of the page instead of at the bottom.
Welcome to the Advanced Custom Fields community forum.
Browse through ideas, snippets of code, questions and answers between fellow ACF users
Helping others is a great way to earn karma, gain badges and help ACF development!
We use cookies to offer you a better browsing experience, analyze site traffic and personalize content. Read about how we use cookies and how you can control them in our Privacy Policy. If you continue to use this site, you consent to our use of cookies.