简体   繁体   中英

Add Geolocation On Wordpress Homepage

i have any issue implements Geolocation use HTML5 like in here https://developers.google.com/maps/documentation/javascript/examples/map-geolocation

if i try to implements, i can get the location (lat, long) but the problem is i can not use it in the content, i have try it to save in cookie or in local storage but its same, i can not detect it in the homepage(content).

Can someone give me advice how to implements it?

i have try use wordpress plugin (wpgeolocation) but the result its not great

Thanks

You are using the javascript api for geocoding, which means that you will not be able to use the geocoding data on the server in your php code or theme.

So you have a few options:

  1. Use a plugin. (You didn't say what was wrong with the wpgeolocation plugin, but there are other plugins that can help you out).
  2. Do geocoding in PHP on the server using something like geocoder . It's definitely more involved and requires more coding.
  3. Modify your content via javascript using the results you got from the Google Geocoding Javascript API.

The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM