fbpx
Register & define a Google Maps API key to allow the location field to work correctly.

First register a API key for Google Maps then include the following snippet to register the key with ACF. This snippet has two parts — one part defines a constant containing the key, the other hooks into the Google Map ACF field and set the key on the fly.

<?php
// Define this in the site's wp-config.php file.
define('GOOGLE_API_KEY', 'your-google-api-key-here');
// Add this to your functions.php file, or a config plugin/MU plugin.
add_action( 'acf/init', function () {
acf_update_setting( 'google_api_key', GOOGLE_API_KEY );
} );

Keep up to date with all things ACF!

Subscribe to our newsletter or follow @awesomeacf on Twitter!