Title: REST API and Geo data
Last modified: January 20, 2021

---

# REST API and Geo data

 *  Resolved [ngow](https://wordpress.org/support/users/ngow/)
 * (@ngow)
 * [5 years, 4 months ago](https://wordpress.org/support/topic/rest-api-and-geo-data/)
 * Am using the WordPress 5.6 Rest API via javascript to create posts. All works
   well in that posts are created/updated correctly.
 * But want to be able set geo data for the created posts, specifically the geo_latitude,
   geo_longitude and geo_address post meta fields.
 * Is this possible via the REST API and if so how do you specify the latitude and
   longitude?

Viewing 4 replies - 1 through 4 (of 4 total)

 *  Moderator [bcworkz](https://wordpress.org/support/users/bcworkz/)
 * (@bcworkz)
 * [5 years, 4 months ago](https://wordpress.org/support/topic/rest-api-and-geo-data/#post-13935057)
 * It’s possible if the appropriate meta fields have been exposed to the API with`
   register_meta()`. See [https://developer.wordpress.org/rest-api/extending-the-rest-api/modifying-responses/](https://developer.wordpress.org/rest-api/extending-the-rest-api/modifying-responses/)
 * When inserting a post, specify the lat/long values like you would any other meta
   values. Build an associative key/value array and assign it to the post’s “meta”
   item prior to converting the whole thing to JSON. The lat/long values will be
   saved as strings. Format the values in whichever way would be most useful to 
   functions using the values. It’s not normally necessary to type cast from string
   back to a floating number. If it becomes an issue, both PHP and JavaScript have
   ways to type cast values.
 *  Thread Starter [ngow](https://wordpress.org/support/users/ngow/)
 * (@ngow)
 * [5 years, 4 months ago](https://wordpress.org/support/topic/rest-api-and-geo-data/#post-13938387)
 * Thanks for the response, I was using a plugin SimpleLocation, this had the register_meta()
   calls, but had set the ‘show_in_rest’ to false, so very easy to change to true.
 * Hoping the meta value and names to use is easy to sort out.
 *  Moderator [bcworkz](https://wordpress.org/support/users/bcworkz/)
 * (@bcworkz)
 * [5 years, 4 months ago](https://wordpress.org/support/topic/rest-api-and-geo-data/#post-13939204)
 * If you are unable to discern the right key names from source code, use the phpMyAdmin
   app to examine table records. Newly added meta data is normally found at the 
   bottom of the postmeta table.
 *  Thread Starter [ngow](https://wordpress.org/support/users/ngow/)
 * (@ngow)
 * [5 years, 4 months ago](https://wordpress.org/support/topic/rest-api-and-geo-data/#post-13942797)
 * All sorted thanks for your assistance.
 * Correct syntax and naming, so can now set and update the post geo location data
   via the rest api. Javascript example below:
 *     ```
       		var post_data = {
       			id:o_post.id,
       			title:"Title",
       			content:"Content of the post",
       			categories:"1,2",
       			tags:"5,6,7",
       			meta:{
       				geo_latitude:"51.4411688",
       				geo_longitude:"-0.2746582",
       				geo_address:"Park",
       				geo_public:"1",
       			},
       			status:"publish",
       		};
       var body_data = JSON.stringify(post_data);
       ```
   

Viewing 4 replies - 1 through 4 (of 4 total)

The topic ‘REST API and Geo data’ is closed to new replies.

## Tags

 * [api](https://wordpress.org/support/topic-tag/api/)
 * [latitude](https://wordpress.org/support/topic-tag/latitude/)
 * [posts](https://wordpress.org/support/topic-tag/posts/)
 * [rest](https://wordpress.org/support/topic-tag/rest/)

 * In: [Developing with WordPress](https://wordpress.org/support/forum/wp-advanced/)
 * 4 replies
 * 2 participants
 * Last reply from: [ngow](https://wordpress.org/support/users/ngow/)
 * Last activity: [5 years, 4 months ago](https://wordpress.org/support/topic/rest-api-and-geo-data/#post-13942797)
 * Status: resolved

## Topics

### Topics with no replies

### Non-support topics

### Resolved topics

### Unresolved topics

### All topics
