• Is it possible to restrict the Featured locations to only display in a certain region (x miles away) or postal code(s) area after a user searches?

    It wouldn’t make sense for Boston locations to show up in a search for Chicago.

    Also can we limit the amount of locations, say display the first closest 5?

    I’m comfortable with code. Thanks!

Viewing 1 replies (of 1 total)
  • Plugin Author Tijmen Smit

    (@tijmensmit)

    The only way I can think of doing this by using the wpsl_store_data filter.

    This allows you to modify the search results just before they are returned. Normally whether or not featured locations are included depends on the used search radius / max results values, so you could indeed end up with featured locations from city a while the user searched for city b.

    But when you loop over the search results with the wpsl_store_data filter, you can create two arrays. One that holds the featured locations and the other one the normal results. Then look for the city value for the first row in of the normal results array, and compare that with the city value of the featured locations array. Remove everything that doesn’t match and merge them again. You can also use this to limit the number of featured results.

    If you want to limit the number of results for the search in general, then you can do this by in the ‘Max search results’ field on the WPSL settings page. The default value has to go between [].

    I didn’t test the above, but it should work.

Viewing 1 replies (of 1 total)

The topic ‘Featured location by Region and Postal code’ is closed to new replies.