Switching out field names for search parameters

Discussion in 'GeoCraft WordPress Theme' started by rosiealiceb, Feb 23, 2018.

  1. rosiealiceb

    rosiealiceb New Member

    Joined:
    Jan 31, 2018
    Messages:
    10
    Likes Received:
    0
    Hi, I found a previous thread with the following query (in bold below). Ink Themes posted a screenshot of how to switch out the field names but it's no longer live. Could you post the steps to do this here? I'd like to do the same thing ...

    Hi
    I've looked through the forum and haven't been able to see a solution to this yet.

    I would like to change the search location function to search a custom field that I have added ( geo_areascovered) rather than the address (geo_address - which is one of your custom fields).

    For example - a tow truck company based in starcity but also covers mooncity and spacecity. They would enter their base address in geo_address and then enter all their areas into geo_areascovered. This then shows up on their listing and enables a wider search.

    With an adjusted search parameter a customer would find the business by searching any of the three locations.

    I would assume it is a question of changing the sql query to reflect the different meta_key and meta_value, but I am not good enough with php and mysql to do this with the correct syntax.

    I hope you can help with this.

    Many Thanks

    Lee
     
  2. rosiealiceb

    rosiealiceb New Member

    Joined:
    Jan 31, 2018
    Messages:
    10
    Likes Received:
    0
    So, after much banging of my head against the wall and a few days of trial and error I have solved this myself. To clarify, the location search box now queries a custom location field rather than the address field. This means that my users can now see results returned for several towns rather than just one. Here is what I did in case anyone else wants to do the same.

    1. Create the new field you want queried and add location data to all listings.
    2. In the file editor, locate the file called class_advance_search.php - In my file manager system this was located under Library/Controls
    3. Open the file and scroll to the section starting at line 112 (Returning search result)
    Lines 128 & 139 & 167 show this: 'key' => 'geo_address', - all you need to do is replace the geo_address part with your own field name
    4. The scroll down further to the next section which starts at roughly line 393 (Instant search by location)
    Make the same switch with field names as above at line 423
    5. The save and close.

    I have done some testing and this has worked for me. However it's easy to reverse if it doesn't work. The only thing is that I can't figure out the logic for the order listings are displayed in the results list. But one win at a time!
     

Share This Page