Place Search Form on Static WordPress Page

This topic contains 8 replies, has 2 voices, and was last updated by  Paolo 9 years, 6 months ago.

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

Open Support Ticket
  • Author
    Posts
  • #18814

    Fearless_Shultz
    Free User
    Post count: 46

    Hi All,

    Not sure if this is the right forum to post in so apologies if not.

    Thanks to some guidance from Simone I am working on a modified version of the search form that allows me to manually set a list of drop down options for the keyword to search for and the location so for example, I have a list of towns that I want the user to be able to select from and also a list of activities.

    I would also like to be able to place the search form on various static WordPress pages, adjusting the list of keywords to select from based on the page and am just wondering what is the best way to go about implementing this?

    I am using the Visual Composer plugin to create page layouts but this doesn’t allow for php blocks. I had wondered if I could just create a html form that passed the relevant form fields on the query string to the appropriate url by setting the action method of the form but based on the location selected, it also seems that it is required to get the lat and long of the place which obviously a static form won’t do.

    I am wondering if a) this is possible to do relatively easily and b) if someone can point me to examples or give me a snippet to work with?

    Hope I have explained this clearly enough but please let me know if I need to clarify anything I know this counts as customisation and am not expecting a full blow solution, just a starting point 🙂

    Kind Regards

    Mike

    #18838

    Paolo
    Site Admin
    Post count: 31206

    Hi Mike,

    It will not be possible to do it relatively easily and it will definitely require to modify the advance search addon with custom code.

    If you want I can move this in the job section of the forum.

    Let me know,

    Thx

    #18847

    Fearless_Shultz
    Free User
    Post count: 46

    Hi Paolo,

    Thanks for your reply.

    Thinking about it, if I have an html form on a page, could I not submit the field values (including the city name) to an intermediary php page that runs a sql query to get the longitude and latitude from the geodir_post_locations table and then redirect to a url with those values appended to the url?

    This would mean I should be able to easily construct the following:

    
    
    ?geodir_search=1&stype=gd_accommodation
    &s=guesthouse&snear=cashel
    &sgeo_lat=52.516757&
    sgeo_lon=-7.887674699999934

    I’m not asking for assistance in putting this solution together, just wondering if in theory this should work? I can create the query and forwarding code etc myself.

    Many thanks

    Mike

    #18848

    Paolo
    Site Admin
    Post count: 31206

    Hi again,

    if you pass the variables via an intermediary php page to the search URL, I don’t see why it shouldn’t work correctly.

    After all you can edit the URL manually on the address bar and perform different queries.

    Thx

    #18849

    Fearless_Shultz
    Free User
    Post count: 46

    Cool, thanks I will try that. It’s one of those cases where once you think through what you are trying to do to explain to someone, a simple solution becomes obvious.

    Also, I wasn’t sure if just passing the correct url parameters would be sufficient but as you say, amending the search results url returns expected results so no reason it shouldn’t work 🙂

    Thanks again.

    Mike

    #18861

    Fearless_Shultz
    Free User
    Post count: 46

    Solution above working well 🙂

    I’ll post the form html, php and sql query once I’ve tidied it up a bit in case it helps anyone else looking to do the same thing 🙂

    #18876

    Fearless_Shultz
    Free User
    Post count: 46

    Hi Again,

    When generating the url to display the listing results. Is there a param that I can put in the query string that will show a certain layout by default? When the page loads it is in list view but would like it to be in the grid three format. Is there anything I can add to the below to do this?

    
    
    ?geodir_search=5
    &stype=gd_accommodation&s=hotels
    &snear=cashel
    &sgeo_lat=52.516757
    &sgeo_lon=-7.887674699999934
    #18881

    Fearless_Shultz
    Free User
    Post count: 46

    Ignore last message, I was being an idiot and didn’t properly check the options in the admin settings for default view.

    #18951

    Paolo
    Site Admin
    Post count: 31206

    Excellent, I’ll set this as solved.

    Thx

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

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

Open Support Ticket