Set Google Maps key for ACF Pro

In order for Google Map fields to render correctly when using ACF Pro you need a Google Maps API key. Use this filter to load the key for use by ACF Pro (assumes key has been set as a constant previously).

<?php
define( 'GOOGLE_MAPS_API_KEY', 'your_key_here' );
add_action( 'acf/init', __NAMESPACE__ . '\set_google_maps_api_key' );
/**
* Set Google Maps API key for use in ACF Pro backend.
*
* @since 1.0.0
*/
function set_google_maps_api_key() {
acf_update_setting( 'google_api_key', GOOGLE_MAPS_API_KEY );
}
view raw functions.php hosted with ❤ by GitHub

Reader Interactions

Leave a Reply

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