[ACF] Solution to Google Maps not showing in ACF

ACF (Advanced Custom Fields) is the plugin that I used on almost every client projects. The Google Maps API used to work perfectly fine on ACF. However, due to the update on Google Maps API, it is now required API Key. This article will show you how to solve this problem.

If we select ‘Google Map’ field type and try to use it, we will see this error:

Google Maps no API Key
This is what we will see without API Key

The solution is to acquire Google Maps API Key from Google website. Simply click on ‘Get Key’ button and follow the step, you will get the API key.

After that, put this code in your theme’s functions.php:

function my_acf_init() {
  acf_update_setting('google_api_key', 'xxx');
}
add_action('acf/init', 'my_acf_init');

Replace xxx with your API Key.

When you try to use Google Map field again in ACF, it will work properly.

Google Maps working ACF
Yay! Google Map is working!

Reference: https://www.advancedcustomfields.com/resources/google-map/


Also published on Medium.

Leave a Reply

Your email address will not be published. Required fields are marked *