Home › Forums › Calendar Products › Community Events › Describe Miles after search result
- This topic has 5 replies, 2 voices, and was last updated 10 years ago by
Nico.
-
AuthorPosts
-
March 16, 2016 at 5:39 am #1089614
dcantato
ParticipantIs there a hook to work with so that I can change the miles in a search to say what they are? I changed the general.php file but that will get overwritten with each update. It was the tribe_event_distance() function.
function tribe_event_distance() { global $post; if ( ! empty( $post->distance ) ) { return '<span class="tribe-events-distance">Distance From Location: '. tribe_get_distance_with_unit( $post->distance ) .' miles</span>'; } }I added the words in the span tag around it so that it explained what people were thinking was a random floating number.
March 16, 2016 at 3:25 pm #1090029Nico
MemberHey @dcantato,
Thanks for reaching out to us! I’m afraid I’m not getting you…
Can you give some context on this? Where are trying to change this in the front-end of the site? Maybe a screenshot would help?
Please let me know about it,
Best,
NicoMarch 16, 2016 at 3:28 pm #1090030dcantato
ParticipantOn the main calendar maps page when you search it shows you the results below.
This page:
http://obstacleracingmedia.com/race-calendar/map/Normally above each event it would just have a number in a little box. I modified my site to show what it shows now. But I used a file that I should probably be editing. Is there a hook I can use to add something to my functions.php instead?
March 21, 2016 at 11:03 am #1091912Nico
MemberHi there @dcantato,
Really sorry for the delay in my reply, somehow this ticket was tagged as ‘Waiting for user feedback’ so it went out of my radar last week until the system pointed out I was owing you a reply!
Hopefully there’s a filter to modify the distance output. You can do something like this in your theme’s (or child theme) functions.php file:
/*
* Change default distance label in Map View
*/
add_filter( 'tribe_get_distance_with_unit', 'tribe_custom_distance_label', 10, 3 );function tribe_custom_distance_label ( $distance, $distance_in_kms, $unit ) {
return 'Distance From Location: ' . $distance . ' ' . $unit;
}
Please give that snippet a try and let me know if it works for you,
Best,
NicoMarch 23, 2016 at 8:08 am #1092897dcantato
ParticipantMuch more elegant and sustainable than my editing of general.php, wouldn’t be bad to include in the next update somehow. Thanks again!
March 23, 2016 at 11:23 am #1093017Nico
MemberGlad to be of help on this 🙂
I guess changing how this displays by default won’t be a happy news for all folks. Anyway the tribe_get_distance_with_unit does a good job here!
I’ll go ahead and close out this thread, but if you need help with anything else please don’t hesitate to create a new one and we will be happy to assist you.
Best,
Nico -
AuthorPosts
- The topic ‘Describe Miles after search result’ is closed to new replies.
