Hi I have a geolocation function that Im using for my wordpress based city that I want to use show location related posts based on a web visitor's location.
The function I'm is using this:
<form action="" method="POST" name="u_select_radius" id="u_select_radius">
<select>
<option value="5">5 Miles</option>
<option value="10">10 Miles</option>
<option value="20">20 Miles</option>
<option value="50">50 Miles</option>
<option value="100">100 Miles</option>
</select>
<input type="submit" value="Search" name="Search" class="blue" />
</form>
<?php //begin geoposty demo
$localCoupons = new WP_Query('post_type=post&posts_per_page=-1&orderby=meta_value&meta_key=City&order=ASC');
if ($localCoupons->have_posts()): while ($localCoupons->have_posts()): $localCoupons->the_post();
if (function_exists('geoDistanceFrom') && $city != '' && $state != '') {
///get user radius selection
if ( isset($_POST['u_select_radius'])) {
$radius = intval($_POST['u_select_radius']);
} else {
$radius = 100;
}
if (geoDistanceFrom($city . ',' . $state) < $radius /* Mile radius */) {
echo '<h3>' . get_the_title() . '</h3>';
echo '<p>' . $city . ', ' . $state . '</p>';
// the_content();
}
}
endwhile; endif;
// end geoposty demo
?>
</div>
This function checks if the plugin function (geoDistanceFrom) exists and then check for certain criteria to base the posts on (city and state). Where it shows "100" (the mile radius), I want to allow users to choose the radius they want (Ex. 5, 10, 20, 50, 100, etc)
I think I would need to create an array with predefined values (5, 10, 20, 50, etc) to choose from. I need some help. How do I allow users to choose values for this function?
Please let me know if there is any additional required for this solution.
Thanks a lot!