This is the technical support forum for Toolset - a suite of plugins for developing WordPress sites without writing PHP.
Everyone can read this forum, but only Toolset clients can post in it. Toolset support works 6 days per week, 19 hours per day.
Tagged: CRED API, Custom search, Directory and classifieds sites, Displaying post relationships, Forms with post relationships, How to build a site with Toolset, Post-relationship, Toolset Forms, Types plugin, Views API, Views plugin
I'm building a directory site.
When creating a listing I'd like the client to be able to click a state dropdown, followed by a city dropdown when they input the address for their listing.
I'd like the url slug to include the state and city entered by the client, so the URL would be something like: hidden link
Lastly, I'd like the end-user to be able to filter listings with a state/city pair of dropdowns, similar to the real estate site example you have here: hidden link
I imagine this has been accomplished, but I haven't found the correct thread for help yet.
Thanks for the detailed reply.
I was thinking the states and cities could be handled using taxonomies, and that I could figure out a function to customize the URL for just the listing custom post type. It seems like populating the cities taxonomy would be the most difficult thing since there are thousands of cities. Maybe I need to rethink that part...
We don't want to post the clients' full address. We're hoping to do something like craigslist does, with cross streets, city, zip, so the end-user can get a general idea of the listing location. See upload.
I was thinking the states and cities could be handled using taxonomies
To display two separate front-end filters for city and state you must use two separate taxonomies, as opposed to a single hierarchical taxonomy with States as top-level terms and Cities as sub-level terms. Just so you are aware of how that would have to be implemented in the current system.
We're hoping to do something like craigslist does, with cross streets, city, zip, so the end-user can get a general idea of the listing location.
Okay understood. There's no built-in approximation feature for marker placement. You must specify a mappable address or a specific latitude/longitude pair to place a marker on a map. I think some alternatives might be:
- Use one address field for the full address, and a second address field to specify a nearby location. Something like a business, park, neighborhood or other place of interest would work. Place the map marker at that nearby location instead of the actual location. This solution works without any custom code, but does require an extra step during the process of capturing the data for a post.
- Write a custom shortcode that randomizes the lat/long pair of a geocoded address. Return the randomized values so you can use them in the marker shortcode. This is probably the simplest, most practical code-based solution. You can get the lat/long of a geocoded address using the Types field API: https://toolset.com/documentation/customizing-sites-using-php/functions/
- After the actual address is geocoded, you'll have access to the latitude and longitude of that location. Round the numbers off by a decimal place or two, or randomize the values a bit, then submit a reverse geocoding request to the Google Maps API to find a street address closest to that lat/long location. Store the response in another address custom field, and use that address to display a marker on the map. This is pretty advanced stuff, because you'll be using custom code to communicate directly with the Google Maps APIs for Reverse Geocoding.
FYI, I found a very interesting plugin: hidden link
I was able to easily craft a URL that includes the post type, a taxonomy term (for state), a custom field (for city) and the post name. Pretty nice so far.
I'm going to experiment with map marker placement next. I'd like to keep this thread open for a bit if that's ok.
Of course, I'll stand by for your feedback.
The topic ‘[Closed] State and City dropdowns for CRED’ is closed to new replies.