Taxonomy for state city zip

Hi,

I want to create a wordpress website for a client which would help people to find a zip code for a particular city, So people would select a state from the drop down then next dropdown would get populated with cities of the selected state and after selecting the city, the last dropdown would be to select the area of the selected city for which the user wants to see the zip code.

Client has all the data with him, like the list of more than 50k zip codes which are mapped with areas / cities / states, I know this could be done with custom taxonomy and custom posts but need guidance to get this done.

Please help.

Thanks,
Trapti

  • consistech

    Paul,

    Thanks for the prompt reply, so here is the scenario:

    There are some states, each state has some cities and each city has certain areas and every area has a zip code. I want a solution where the user comes to a page and sees three drop down lists,
    First one for State, it has the all of the states -> User selects the state

    Second for City, It would be inactive unless user selects a state, once user selects a state, this drop down gets populated with the city names of that state.

    Third for Area name, It would be inactive unless user selects a city, once user selects a city, this drop down gets populated with the area names of that city.

    Once user selects an area the user is shown the zip code of that area.

    Now, there are few things which I want:

    1. I don't want to enter the 50k+ zip codes, I want to upload the data via sql to the tables with proper relations between the records.

    2. When user comes to the above said page, the Title of the page should be All Zip Codes, Once user selects a state, the state, the title should get appended with <statename> Zip codes, similarly when user selects city then title should be <city> zip codes, <state> zip codes, All Zip codes and similarly for area name as well.

    3. There should be a way for user to refresh the list, lets say after selecting a state, user wants list of all states then he should not refresh the page for this e.g. if user selects Ohio as state then city list gets populated with all cities of Ohio, if user selects Columbus in city and now if he wants to select any other city then he should have a link / button against this dropdown which would refresh the list without refreshing the lists of above selected values.

    I hope I am clear, Please let me know what is the best way to get this done, I am a beginner wordpress developer with basic knowledge.

    Thanks,
    Trapti

  • consistech

    Patrick,

    Thanks for help, I have been trying this plugin and there are some others as well which say that they do the job, but nothing is working as per my requirements.

    The plugin you mentioned, just gives a dropdown of categories which have posts, where as I want hierarchical dropdown with strict parent child relatioship, until and unless I select parent category, child categories should not be populated in the dropdown.

    Can you please help me in this.

  • Will Ashworth

    @consistech

    If you know a bit of PHP and some of the innards of WordPress, you should be able to code this into a view. You can (quite easily) code this into one of your template page views (or create a new one), and basically goes something like this.

    If it were me, I'd store the data in something like ACF, but there's probably a number of ways you can do it. If you truly want to store the raw data in MySQL separate tables, rather than in WordPress, you can just query the database tables directly rather than WordPress' way of doing the queries.

    - select all states from database
    - display all states in dropdown
    - user selects a state
    - select all cities where state = 'chosen state'
    - display all matching cities in new dropdown
    - user selects a city
    - select all zipcodes where city = 'chosen city'
    - list out all matching zip codes on the page
    (since dropdowns are done)

    Probably best to use some AJAX for the WordPress database calls and to generate/display each subsequent select box as a choice is made, allowing them to drill deeper without needing to submit the page (with an ugly refresh).

    Hope this helps!

Thank NAME, for their help.

Let NAME know exactly why they deserved these points.

Gift a custom amount of points.