Knowledge base / WordPress

Where WordPress page builders store the Google Maps API key

A WordPress site can hold a Google Maps key in four or five places at once: the theme, the page builder, an add-on pack, a dedicated maps plugin and the individual map widget. The most specific one usually wins. That is why the map on one page renders and the map on the next one doesn't.

How to tell this is your problem

  • The map works on the contact page but is grey or missing on a landing page or location page.
  • You pasted a new key into the theme settings, but the page source still shows the old one, or no key at all.
  • The map broke straight after a theme, builder or add-on update, or after you switched from one maps plugin to another.
  • The console shows MissingKeyMapError, InvalidKeyMapError or RefererNotAllowedMapError on some pages but not others.
  • The page loads the Maps script more than once, each copy with a different key.

A typical console on an affected page looks like this:

Google Maps JavaScript API error: MissingKeyMapError
https://developers.google.com/maps/documentation/javascript/error-messages#missing-key-map-error

Why it happens

WordPress has no single place for a Maps key. Each product that draws a map ships its own setting, and many also let you set a key on the individual widget or module. A widget-level value overrides the global one without telling you. When one of those fields is empty, holds an old key, or holds a key that is restricted to the wrong API, only the pages using that widget break.

There is a second trap. Some builders draw maps with the Maps Embed API (an iframe), while maps plugins and add-ons usually use the Maps JavaScript API. If your key's API restrictions only allow one of them, half your maps work and half don't, even though every field holds the same key. That shows up as ApiTargetBlockedMapError for JavaScript maps, or an error inside the iframe for embeds.

Where each builder keeps the key

Menu labels change between versions, so treat these as starting points and check the exact wording in your install.

Elementor

Elementor's own Google Maps widget reads its key from Elementor → Settings → Integrations. Elementor's documentation says the widget uses the Maps Embed API, so the key must be allowed to call that API. Third-party Elementor add-on packs often ship their own advanced map widget with a separate key field in the add-on's settings page, and that widget uses the JavaScript API instead. Full walkthrough: fixing Google Maps in Elementor.

Divi

Divi keeps the key in Divi → Theme Options → General, in the Google API key field, alongside a toggle that controls whether Divi loads the Maps API at all. Map modules pick up this key automatically, but the Map module can also hold its own key, which overrides the theme setting. See fixing Google Maps in Divi.

WPBakery

WPBakery's built-in Google Maps element has traditionally taken the iframe code from Google Maps' Share → Embed a map dialog, which needs no key. Many themes and add-ons built on WPBakery add their own map element that does need a key, stored in the theme options or the add-on's settings. See fixing Google Maps in WPBakery.

Other themes and maps plugins

Lightweight themes often have no map feature of their own and rely on a block plugin or add-on, so the key lives in that plugin's settings. Dedicated maps plugins, store locators, directory plugins and form plugins with address autocomplete almost always keep their own key field, and many load their own copy of the Maps script.

The fix, step by step

  1. 01Open an affected page, choose View source and search for maps.googleapis.com and google.com/maps/embed. Note every match and the key= value on each.
  2. 02If you find no key= parameter on the script tag, search the source for importLibrary or key:. Some plugins pass the key in JavaScript using Google's bootstrap loader.
  3. 03Open the builder's global setting listed above and check the key. Then open the map widget or module on the affected page and look for its own key field. Clear the widget-level field, or set it to the same key.
  4. 04Go to Plugins and list everything that might draw a map: maps plugins, store locators, directory plugins, event plugins, form plugins with address fields. Open each one's settings and note its key.
  5. 05Pick one key for the site. In Google Cloud Console, check that its API restrictions include every API the site really uses, typically the Maps JavaScript API, the Maps Embed API, and the Places API or Geocoding API if you have address search.
  6. 06Check the key's website restrictions cover every hostname the site is served from, for example https://example.com/* and https://www.example.com/*.
  7. 07Remove the key from every place that doesn't need it, so there is a single source of truth. Where a plugin insists on its own field, paste the same key.
  8. 08Clear your caching plugin, any server cache and your CDN, then reload the affected page in a private window.
Two keys can mean two loaders

If view source shows two maps/api/js requests, two plugins are each loading the API. Fixing the key won't stop that. See finding the duplicate Maps loader.

Keys that look right but fail

  • A trailing space. Builder fields don't always trim input. A key with a space on the end produces InvalidKeyMapError. See checking the key your page sends.
  • A key from another site. Agencies often reuse a template. The key works on the old domain and fails on yours with RefererNotAllowedMapError. See fixing referrer restrictions.
  • A staging key in production. Migrating a database from staging copies its key settings across too.
  • A key restricted to the wrong API. An Embed-only key used by a JavaScript map widget, or the other way round.

Confirm it is fixed

Scan each template separately: home, contact, each location page and any landing page with a map. A per-widget override only shows up on the page that uses that widget, so a clean contact page proves nothing about the rest. The scan loads each page from a clean session and lists every Maps request and the key it carried, so a stale key on one widget is easy to spot.

In the browser, the console should show no Maps errors and the network tab should show one maps/api/js request per page, all with the same key.

Common questions

Which key wins if the theme and the widget both have one?

In most builders the widget or module value overrides the global setting. If a maps plugin also loads its own script, whichever loader runs first sets the key for the page, and the second one usually triggers a 'multiple times' warning.

Do I need a separate key for each plugin?

No. One key can serve the whole site as long as its API restrictions include every API the plugins use and its website restrictions include every hostname. Separate keys are only useful if you want to track usage per feature.

Why does Elementor's map work without the JavaScript API enabled?

Elementor's core Google Maps widget uses the Maps Embed API, which is a different API from the Maps JavaScript API. A key restricted to the JavaScript API alone will not work for it, and the other way round.

A theme update wiped my key. How do I stop that happening again?

Keep a note of the key's location in each plugin, and after any update scan the pages that have maps. Free monitoring can re-check up to five pages for you and email you when a map breaks.

Check whether this is your error

A scan tells you in about twelve seconds, from a clean session.

Related articles