- The modern way would be to use html5 which does support geolocation: simple demo
- A bit longer explanation how this could be added to a web-app here
- A nice php script that uses a web service called geoplugin (the api is nice, no idea about the company, ymmv!)
- And last but not least, using the html5 geolocation from php (which you would need for wordpress) at stackoverflow
The latter has a nice explanation how to use modernizer which could then combine html5/geolocation with some webservice or something.