WordPress.org

Ready to get started?Download WordPress

Forums

Display front page posts by zip code (4 posts)

  1. MTV
    Member
    Posted 4 years ago #

    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

  2. MichaelH
    Member
    Posted 4 years ago #

  3. MTV
    Member
    Posted 4 years ago #

    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.

  4. tugbucket
    Member
    Posted 4 years ago #

    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/

Topic Closed

This topic has been closed to new replies.

About this Topic