How to show whole region listings when searching for a city

Hello, I have set API’s, keys, regions and everything seems to work fine, but I have a problem when searching for a city.

Here is example to reproduce: I have created listings with a location/city “Bratislava”, and also some listings with it’s whole region that is “Bratislavský Kraj”. When you search for the whole region “Bratislavský Kraj” it shows all the cities in that region which works great.
The problem is when you search for a specific city like “Bratislava” it doesn’t show listings with the whole region like “Bratislavský Kraj”.

When used as a services website, there is a problem when user search for a service listing for a specific city. It should also show the whole region listings because someone is covering the whole region with his services and someone just one city.

I already:

  1. Checked the “Generate Regions from location” - It works and creates cities/regions.
  2. I created a second API key without HTTP restrictions, and I enabled 3 APIs (geolocation, maps, and places).
  3. Pasted the API key with no restrictions in the “Secret key” section in HivePress/Settings/Integrations. Thank you

Is this the intended way of how it works? Or is it a bug? If so, could you please provide some creative solution to this problem? Thank you

Hi,

Thank you for your feedback, we will check this in more detail and fix it in the next updates. If you need to fix this urgently and you have a developer or are familiar with coding, we can provide general guidance. Let me know if this works for you.

Hello I have experience and made multiple snippets and css codes so far, so if you could give me any solution it would be great even if I had to give it to someone more experienced. Solution to this would make a very big difference, so please go ahead. Thank you andrii

Sorry for the delay.

Unfortunately there’s no simple code snippet to implement this, but I can provide developer guidance. This is where the region query is set in the Geolocation code hivepress-geolocation/includes/components/class-geolocation.php at master · hivepress/hivepress-geolocation · GitHub The described functionality can be implemented if you get all the parent region IDs, possible using this function get_ancestors() – Function | Developer.WordPress.org and instead of a single ID, set an array of IDs (the current searched one and all the parent IDs). It’s better to override this query using the hivepress/v1/models/listing/search action hook.

Hope this helps