• Hello,

    I need some help/information.
    I need to expand the standard search query string. Like it is said in this plugin:

    acf-google-maps-radius-search

    So I need to do something like:

    https://page.de/search.php??s=search Key Word&lng=51.023232&lat=12.232323

    Is there a HOOK for the search query so I can add the

    &lng=51.023232&lat=12.232323

    ?

    Thanks for help,
    Denis

Viewing 5 replies - 1 through 5 (of 5 total)
  • In the context of search, the query parameters are fields in the search form. To add lat and lng to the search you would include fields for lat and lng in the search form. If they have pre-defined values that the user cannot change you can make these hidden type inputs.

    • This reply was modified 6 years, 4 months ago by Jacob Peattie.
    Thread Starter DenisCGN

    (@deniscgn)

    Hello Jacob,
    thanks for your answer. To test my query I will use the hidden fields.
    But in futur I like the LAT & LNG to be dynamic, cause of what the visitor is came from.
    So I need some HOOK or anything else, to modify the query URL with the visitors GEO data (lat & lng).
    Cheers,
    Denis

    You don’t need a hook to modify the URL, just use whatever function determines the user’s location to populate the hidden fields.

    Thread Starter DenisCGN

    (@deniscgn)

    Hello Jacob,
    so I need to do it with JAVA Script or someting? Cause the user should finally only enter his Postcode and/or his address. Then before sending the search form the postcode must be transformed into lat/lng ??
    This seems to be a bit tricky.
    therefor I think it seems to be esier to hook into the query and then do int via the functions.php.

    I must say that is a real cross to do a radius/geo seaarch with wordpress (without using a not fitting theme :-))
    Cheers,
    Denis

    Moderator bcworkz

    (@bcworkz)

    FWIW, query vars can be altered in the “request” filter, but because ALL requests go through this filter, it may not be the best approach.

    If lat/lng is unknown to the form, but can be determined server side from post code or address, it’s better to do this in the server side form handling code. The form handler can do it all, including instantiating a WP_Query object to do the search and generating the output from the results. This will be more efficient than feeding the lat/lng determination back into another WP request.

Viewing 5 replies - 1 through 5 (of 5 total)
  • The topic ‘Expand Search Query String’ is closed to new replies.