Tag Info

Hot answers tagged

9

I would modify the answer from gabrielk and the linked blog post by using database indexes and minimizing the number of actual distance calculations. If you know the coordinates of the user and you know the maximum distance (say 10km), you can draw a bounding box that is 20km by 20km with the current location in the middle. Get these bounding coordinates ...


7

First you need a table that looks something like this: zip_code lat lon 10001 40.77 73.98 ...populated for each zip code. You can expand on this by adding city and state fields if you want to look up that way. Then each store can be given a zip code, and when you need to calculate distance you can join the lat/long table to the store ...


6

This might be too late for you, but I'm going to reply anyway, with a similar answer as I gave to this related question, so future visitors can refer to both questions. I would not store these values in the post metadata table, or at least not only there. You want a table with post_id, lat, lon columns, so you can place an index of lat, lon and query on ...


4

you can change your search filter to this: function SearchFilter($query) { $post_type = $_GET['post_type']; if (!$post_type) { $post_type = 'any'; } if ($query->is_search) { $query->set('post_type', $post_type); }; return $query; } add_filter('pre_get_posts','SearchFilter'); then on your news search form add : <input type="hidden" ...


4

What precision do you need? if it's a state/national wide search maybe you could do a lat-lon to zip lookup and have precomputed distance from zip area to zip area of the restaurant. If you need accurate distances that won't be a good option. You should look into a Geohash solution, in the Wikipedia article there is a link to a PHP library to encode decode ...


4

There's Geo Data Store by our own man, @Brady. It does a perfect job in one of my installations. It uses a custom table, that stores only ID, meta ID, lat and lng information, so your queries stay quick and brief, even when your database starts scaling. It got a 5 star rating from my side. This plugin is meant to be used by other developers and to be ...


3

The MySQL documentation also includes information on spatial extensions. Oddly, the standard distance() function isn't available, but check this page: http://dev.mysql.com/tech-resources/articles/4.1/gis-with-mysql.html for details on how to "convert the two POINT values to a LINESTRING and then compute the length of that." Note that every vendor is likely ...


2

You can definitly use PHP session variables. Follow this blog post ("Listing 3") for the best way to enable PHP sessions in WordPress. Namely, you need to use this code in your plugin or in your theme's funtions.php: add_action( 'init', 'session_start', 0 ); After that you can use basic session variables to set the country when the user selects it, and ...


1

This isn't a WordPress question, its more suitable for StackOverflow. Regardless, your looking for a chained menu. I've seen this tutorial around a lot, hope it helps.


1

There are a lot of pieces to this puzzle. You need to be able to convert the postcodes into a numerical data format so you can query the pages/posts with "is greater than [current location minus 5 miles] and less than [current location plus 5 miles". In two dimensions. This means storing the latitude and longitude with the page. You can automate this, so ...



Only top voted, non community-wiki answers of a minimum length are eligible