Support

Account

Home Forums ACF PRO Add Google Maps API Key to a theme

Solved

Add Google Maps API Key to a theme

  • Hey,

    I’m not quite sure how to add the Google Maps API Key to my theme.

    I used following filter and this this is working well within the backend:

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

    It’s working within the frontend if I enqueue the Google URL seperately again within the functions.php. So what is the correct way? Using the filter AND adding the google api link seperately?

    <script src="https://maps.googleapis.com/maps/api/js?key=YOUR_API_KEY"></script>

    And I got another general question:
    What exactly is the google_api_client? What do I use it for?

    Cheers
    bahemian

  • Hi @bahemian ,

    Thanks a lot for reaching out to us.

    Both method are required for the map to work both on the frontend and the backend.

    The first one is used by the plugin enqueueing the google map jquery in the backend.

    The second one provides the api-key parameters for loading the google map js on the front end.

    I hope this helps.

Viewing 3 posts - 1 through 3 (of 3 total)

The topic ‘Add Google Maps API Key to a theme’ is closed to new replies.