Support

Account

Home Forums Front-end Issues WP Query closest locations by ACF Google Map values Reply To: WP Query closest locations by ACF Google Map values

  • @mastababa If this needed to be done for thousands of locations what I would do would be to create an action that started a CRON job that would do all of the cacluations. I would likely create some type of complex array of data that would store all of the needed information to allow for easy retrieval of the information. How that might look would depend on what I wanted to do.

    Let’s say that I wanted to do what the OP was doing and show the closes 3 other locations. My array would probably look like this.

    
    $option = array(
      // each element of this array is a post ID => array of closest 3 posts
      1234 => array(1567, 7657, 5654),
      // etc
    )
    

    You can then just grab the post ID’s to get from this array.

    Doing the CRON that does all the indexing would be beyond my ability to help here.