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:

 

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
  3. Save the file,

It’s as simple as that. Enjoy.