Search URL Structure: Category Plus Zip Code

This topic contains 7 replies, has 2 voices, and was last updated by  Guust 7 years, 8 months ago.

We have moved to a support ticketing system and our forums are now closed.

Open Support Ticket
  • Author
    Posts
  • #266590

    Jacob Paulsen
    Full Member
    Post count: 45

    How do I create a search that looks for places in a specific place category and near a specific zip code?

    Category seems to be easy: domain.com/places/category
    Zip is hard. From what I can tell if I type a zip code into the near field and do a search it somehow creates a search url with long/lat
    For example:
    domain.com/?geodir_search=1&stype=gd_place&s=+&snear=80005&sgeo_lat=39.854992&sgeo_lon=-105.1317431

    So there are two questions here…

    First, is there a way to generate a search via a zip code with a URL? (IE traffic coming from an external site and should lead to a search results page based on zip code)

    Second, can that be done for a single place category?

    #266648

    Guust
    Moderator
    Post count: 29970

    The lat and the lng in the URL is the center of the area of that post code. You can change the ZIP if you like, the results are governed by your set radius around the lat and lng. In other words, the search looks for listings within a set radius of the lat and lng, regardless of the ZIP code.

    Use the category ID as per example below.

    /?geodir_search=1&stype=gd_place&s=+&snear=10013&sgd_placecategory%5B%5D=2&sgeo_lat=40.7217861&sgeo_lon=-74.00944709999999

    #266676

    Jacob Paulsen
    Full Member
    Post count: 45

    Guust, thanks for taking the time for me!

    I’m not sure if I’m clear. If I just want to generate a search page via Direct URL and I don’t know the lat and the lng can I still generate the search via zip only?

    If I use this search string for example:
    ?geodir_search=1&stype=gd_place&s=+&snear=80005

    it will not work. It doesn’t auto query and input the lat/lng into the search query.

    Also I tried to add &sgd_placecategory=catname to a search query and it didn’t filter to that category.

    Example: /?geodir_search=1&stype=gd_place&s=+&snear=80005&sgeo_lat=39.854992&sgeo_lon=-105.1317431&sgd_placecategory=catname

    #266975

    Guust
    Moderator
    Post count: 29970

    I think you were clear: you want to search near the center of a specific ZIP code and only within a specific category

    The search looks for listings within a set radius of the lat and lng, regardless of the ZIP code.
    Use the category ID as per example below.

    Therefore the search URL needs to include
    * the lat and lng of the center of the ZIP code
    * the radius of the area you want to search around the center of the ZIP code (which is not in the URL but at GD > General > Search tab
    * the category ID – not the category name

    You cannot generate the search via ZIP only in a URL, you can search for a ZIP in the search widget and that will give you the lat and lng you got to use in the URL.

    #266976

    Jacob Paulsen
    Full Member
    Post count: 45

    Ok, got it. You answered my question. What I want to do can’t be done. Thanks again for your time!!!

    #266982

    Guust
    Moderator
    Post count: 29970
    This reply has been marked as private.
    #266983

    Jacob Paulsen
    Full Member
    Post count: 45

    I get it now. You are being very helpful. I do want to dynamically create a link from an external site with zip code only that will generate search results on the directory site. Sounds like I can’t do that. I would have to have a script that generates the lat/lng from the zip and then sends the url over to the directory. Correct?

    #266990

    Guust
    Moderator
    Post count: 29970

    Yes, that seems correct.

Viewing 8 posts - 1 through 8 (of 8 total)

We have moved to a support ticketing system and our forums are now closed.

Open Support Ticket