Automatically Locate Users

Our Extended Location plugin allows “Auto City Suggest” which will automatically suggest a location to search for based on the user’s IP location. This can sometimes be inaccurate if you have a dynamic IP, are behind a proxy, etc. 

The code below will automatically “click” the autolocate button the Location field of your search filters. This will ask the user for authorization to use their web browser’s API to more accurately locate them. After the initial authentication they will not be asked again.

This code cannot be used when Extended Location’s “Auto City Suggest” feature is enabled.

Place the following code in your child theme’s functions.php file:

If you’d like to only enable auto locate on the homepage, please use the code below instead:

If you are using FacetWP, you can use:

Was this article helpful?

Related Articles