Skip to content

Documentation

Extensive Documentation for PowerPack & WooPack to help you with common questions and issues.

PowerPack

  1. Home
  2. Docs
  3. PowerPack
  4. Modules
  5. Google Maps
  6. Fetch Latitude & Longitude from ACF Pro GoogleMap Field?

Fetch Latitude & Longitude from ACF Pro GoogleMap Field?

ACF Pro provides a GoogleMap field which makes it easy to add locations to the posts via a nice graphical interface. You can easily fetch the latitude, longitude, and name data from this custom field by creating a custom shortcode and using it in the Google Map module.

ACF Pro Google Map Field in Post Editor Window
ACF Pro Google Map Field in Post Editor Window

Creating shortcode

  1. Add the following code to the functions.php file of the active theme.

Using Shortcode to Fetch Latitude and Longitue

The shortcode that we have created above can be used to fetch following fields :-

  • lat
  • lng
  • zoom
  • place_id
  • street_number
  • street_name
  • street_name_short
  • city
  • state
  • state_short
  • post_code
  • country
  • country_short

For example, if the ACF Pro Google Map field name is googlemap then a shortcode can be used like this to fetch the latitude.

[my_map field="googlemap" sub="lat"]

Using the Shortcode in PowerPack Google Map Module

  1. Set the source to ACF Repeater Field
  2. In the latitude field add the following shortcode [pp_map field=”googlemap” sub=”lat”]
  3. In the longitude field add the following shortcode [pp_map field=”googlemap” sub=”lng”]
Using Shortcode in PowerPack Google Map Module
Using Shortcode in PowerPack Google Map Module
Was this article helpful to you? Yes No

How can we help?

×