Join our new community forum for support & discussion

Join Now

Home Support Extensions Geolocation How to generate region for all the listings

How to generate region for all the listings

  • Author
  • Inspares

    It is really hard to edit the location of all the listings one by one to generate regions.
    I have 1000+listings, is there any option to generate regions for all the existing listings automatically.

    yevhen developer

    Please try this PHP snippet as temporary solution for listings created before the Regions feature release. Once you add it, please refresh the home page until all the regions are created, then delete this snippet (otherwise it’ll slow down the site):

    	function() {
    			$listing_ids = HivePress\Models\Listing::query()->order('random')->limit(50)->get_ids();
    			foreach ($listing_ids as $listing_id){
    				do_action( 'hivepress/v1/models/listing/update_longitude', $listing_id );	

    I used the above code to generate regions. But seems am still confused with location search. I still have an issue where if i enter “India”, no results are displayed. but if I enter City, India then listing come up in search result.

    I followed both the steps of 1)Generating region 2) above code to update existing listings , but still no luck.

    Could you please suggest what am i missing.

    yevhen developer

    Please check if regions were generated after you used the above code snippet in Listings/Regions. If no regions were generated please make sure that you use a Google Maps API key without HTTP restrictions, or another option is using Mapbox (their API is easier for generating regions). Once you generate regions and India appears in Listings/Regions, listings will be found via the country search.


    @yevhen have you a tutorial for this new fonction? I’m interesting but I don’t understand how to install it

    yevhen developer

    We do not have one yet, but it is pretty simple – once you enable it in settings, regions will be generated automatically in Listings/Regions, these are similar to listing categories. Please make sure that there is an API key without HTTP restrictions (restrict quotas instead if required), we recommend using Mapbox for regions instead of Google Maps.


    ok and we can classify and display the regions as we want or it’s automatic (only cities or countries)? I will try soon to see the rendering

    yevhen developer

    If you mean code snippet above then once you add it regions will be created automatically on each refresh of some page of your website. We recommend to refresh the home page until all the regions are created, then delete this snippet (otherwise it will slow down the site):

Viewing 8 posts - 1 through 8 (of 8 total)

New Reply

This forum has been archived and is no longer accepting new posts or replies. Please join our new community forum for support & discussion.