• I’m looking for a plugin that able to show a specific category to assigned destination. For instant, I set category A to California , category B to New York, etc… visitors. So if a visitor from California, the posts from category A will be displayed on the front page instead of showing latest posts

Viewing 3 replies - 1 through 3 (of 3 total)
  • 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:

    https://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/

Viewing 3 replies - 1 through 3 (of 3 total)
  • The topic ‘Display front page posts by zip code’ is closed to new replies.