Need assistance with a PHP script which will look up events within a specified mile search of a zip code and display them. The event zip codes are in the database as part of a WordPress custom post type without lat and long entries. I'm thinking a zip code table could be added with all zips/lat/long entries for the lookup. Tried a couple plug-ins and they are all too bulky, I’d dive into it myself but the time line for the project is short. I'd like the code to be as light as possible and delivered so I can pop it into my current setup. Thanks!
Or perhaps the lat and long could be looked up on the fly with Google Geocoding
The ongoing events are added via WordPress as a custom post type, each is added to the database as a single post. The zip code is a custom field in a separate table linked by the post ID. Each event will have its own zip code, multiple events may share a zip code.
The post entry is in the wp_posts table the zip code is stored in the wp_postmeta table linked by the post ID. It’s not a taxonomy but a custom field stored with a meta_key of zip_code and a meta_value of the actual zip code.
There is no current search page, what I’d like it to look like is enter any portion of an address and radius to search, returned is a Google map showing the events and a list below of events with pertinent event info.
If I was going to list all zip codes currently in the database I’d use the following:
if (have_posts()) : ?>
<?php while(have_posts()) : the_post();
$zips = get_post_meta($post->ID, 'zip_code', $single = true);
<?php endwhile; ?>
<?php endif; ?>
<?php wp_reset_query(); ?>