Thread Starter
MTV
(@mtv)
Hi Michael,
It’s a useful plugin but it’s not what I was looking for. Let’s say, I want set zipcode for category A. So when visitor enters his/her zipcode, the latest posts from that category A will show on the front page.
You could do something like this. Give each post a tag that includes the zip code. then run a search for them. you’ll want to clean the input before submitting so a process page would be nice. It’s a simple example.
<form>
<input type="text" name="zip" value="" />
<button type="submit">Submit Zip</button>
</form>
<br />
<ul>
<?php
global $post;
$zip = $_GET['zip'];
$zip = ereg_replace("[^0-9]", "", $zip);
$myposts = get_posts('numberposts=3&tag='.$zip);
foreach($myposts as $post) :
?>
<li><a href="<?php the_permalink(); ?>"><?php the_title(); ?></a></li>
<?php endforeach; echo $zip; ?>
</ul>
this is very limiting though. If I type in my zip code, and only postts that show are in that zip code, unless you have millions of articles, the odds of me finding anything is slim. a radius effect might be handier:
http://www.dougv.com/blog/2009/03/27/getting-all-zip-codes-in-a-given-radius-from-a-known-point-zip-code-via-php-and-mysql/