ACF: How to set Google Maps API key

I am using Advanced Custom Fields for WordPress, and within that, I am trying to use the Google Maps field type.

After installation, there is no API key set for the usage of the Google Maps API, so you need to set it yourself. If you do not, you will get an error in the developer console of your browser:

If you like this content and found it helpful, please consider supporting me with a small donation.

Google Maps API error: MissingKeyMapError https://developers.google.com/maps/documentation/javascript/error-messages#missing-key-map-error
Google Maps API warning: NoApiKeys https://developers.google.com/maps/documentation/javascript/error-messages#no-api-keys

 

Here are the steps involved to save your API key for your Advanced Custom Fields Google Maps field type:

  1. Get an API key from Google
  2. Open your theme’s function.php and put the following code
    function my_acf_google_map_api( $api ){	
    	$api['key'] = 'YOUR_GOOGLE_MAPS_API_KEY';	
    	return $api;	
    }
    
    add_filter('acf/fields/google_map/api', 'my_acf_google_map_api');
    
  3. Save the file,

It’s as simple as that. Enjoy.

Veröffentlicht von

Christian Hänsel

Web-Entwickler, Experte für technisches SEO. ich liebe meinen Job, meine Familie und den Libanon. Fragen? Mail: chris@haensel.pro.

Schreibe einen Kommentar

Deine E-Mail-Adresse wird nicht veröffentlicht. Erforderliche Felder sind mit * markiert.

Diese Website verwendet Akismet, um Spam zu reduzieren. Erfahre mehr darüber, wie deine Kommentardaten verarbeitet werden.