Home › Forums › Calendar Products › Events Calendar PRO › (how to) sort events by distance?
- This topic has 9 replies, 4 voices, and was last updated 7 years, 5 months ago by Francesco.
-
AuthorPosts
-
October 24, 2016 at 2:42 am #1181794FrancescoParticipant
Hello,
is there a way to sort the events by distance?
I mean: after performing a search, an user would normally expects to see the events displayed by distance, with the closest event listed as first.If there is no “offical” way to do it, can you tell me which file manage that loop?
Thanks in advance,
fOctober 24, 2016 at 2:45 am #1181795FrancescoParticipantBTW: I see that distances are not accurate: there’s always some hundred meters of difference between the real distance and what is actually displayed… It seems that the system calculates the route on foot but it is shorter of 300mt or stuff like that. Any idea?
- This reply was modified 7 years, 6 months ago by Francesco.
October 24, 2016 at 6:29 pm #1182223CliffMemberFrancesco, this is a neat idea.
You could request this as a new feature (or maybe search to see if the idea was already posted by someone else) at our plugins’ UserVoice page.
This allows others who are interested in that feature to easily voice their support. We frequently review suggestions there to find out which ones are popular, then we implement as many of them as we can.
If you post it / find it, feel free to link to it from here in case anyone comes across this forum thread in the future.
===
As far as a file to look into, I’d suggest starting out by referencing /wp-content/plugins/events-calendar-pro/src/Tribe/Geo_Loc.php
tribe_get_distance_with_unit() is used in that file but defined in /wp-content/plugins/events-calendar-pro/src/functions/template-tags/general.php
Please let me know if you have any follow-up questions on this topic.
October 25, 2016 at 8:31 am #1182469FrancescoParticipantThanks for answering.
I guess that I should find where the results are displayed in loop.
If they are stored into an array maybe they can be reorderd.
Or maybe this is just a silly idea.
Anyway, if you can tell me more I will appreciate!I’ve posted my suggestion in the provided link.
But I would venture to say that if I can perform a search by address I should have the nearest place as first result… and then the other one placed depending on the distance…f
October 25, 2016 at 2:57 pm #1182825CliffMemberThat Geo_Loc.php file has setup_geoloc_in_query() hooked into tribe_events_pre_get_posts.
That might be the function to look into. However, it looks like that function only gets the Venues within a geofence area without any sorting.
There’s also add_event_distance() that gets output in the Photo View: /wp-content/plugins/events-calendar-pro/src/views/pro/photo/single-event.php
You might be able to leverage something like these (and other functions you may find) to hook into tribe_events_pre_get_posts (possibly with a different priority).
If you do figure this out, feel free to share your code for others to benefit from — or for us to possibly implement into the core code of PRO in a future version.
Again, you could/should submit the idea on UserVoice.
October 26, 2016 at 1:33 am #1183061FrancescoParticipantThank you for your help.
I’ll try something starting from your hints.
And, of course, I’ll share my results if they will work!Yesterday I’ve posted the request in user voice as suggested
https://tribe.uservoice.com/forums/195723-feature-ideas/suggestions/16804615-sort-events-by-distanceRegards
fOctober 26, 2016 at 1:36 am #1183063FrancescoParticipantHere’s my post to be voted if someone should find this feature useful:
https://tribe.uservoice.com/forums/195723-feature-ideas/suggestions/16804615-sort-events-by-distance
October 26, 2016 at 10:25 am #1183300CliffMemberThanks for sharing that link here.
I’ll leave this thread open for a time in case you have code to share, but please note that threads get Closed automatically after a couple weeks of inactivity. If it does get Closed, feel free to open a new thread, adding your current problem description and also linking back to this thread.
Thank you!
November 17, 2016 at 8:35 am #1193895Support DroidKeymasterHey there! This thread has been pretty quiet for the last three weeks, so we’re going to go ahead and close it to avoid confusion with other topics. If you’re still looking for help with this, please do open a new thread, reference this one and we’d be more than happy to continue the conversation over there.
Thanks so much!
The Events Calendar Support Team -
AuthorPosts
- The topic ‘(how to) sort events by distance?’ is closed to new replies.