Posts Locator Function - gmw_update_post_location

* Note that this function is  compatible  with GEO my WP version 3.0 or higher. For previous versions of GEO my WP see the function gmw_pt_update_location().

This function is one of GEO my WP's most important functions. This function is responsible for saving posts location into GEO my WP custom database table, which then makes the post searchable via GEO my WP search forms. 

With GEO my WP, by default, it is possible to geotag a post via the location form of the "Edit Post" page of the admin's dashboard only. However, using this function you can sync an address provided via a front-end form with GEO my WP. 


gmw_update_post_location( $post_id, $location, $user_id, $location_name, $force_refresh );


  • $post Id ( integer ) - the ID of the post being updated with a location.
  • $location ( string || array ) - can be a string of an address, an array of address fields, or array of coordinates. The array of address fields accepts any or all of the keys 'street', 'apt', 'city', 'state', 'zipcode', and 'country'. The array of coordinates must include the 'lat' and 'lng' keys.
  • $user_id ( integer ) - the ID of the user associated with the location. The default will be the post author.
  • $location_name ( string ) - the title of the location. This by default will be the post's title, which is what GEO my WP supports by default when displaying locations. A custom location should be used when multiple locations exist per post, which is not supported by default.
  • $force_refresh ( boolean ) - true to force GEO my WP to geocode the address even if it already exists in the internal cache. Default set to false, which means that GEO my WP will use the cached geocoded data, when possible.


General Usage

Integration with Events Manager plugin