Describe Miles after search result

Home Forums Calendar Products Community Events Describe Miles after search result

Viewing 6 posts - 1 through 6 (of 6 total)
  • Author
    Posts
  • #1089614
    dcantato
    Participant

    Is 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.

    #1090029
    Nico
    Member

    Hey @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,
    Nico

    #1090030
    dcantato
    Participant

    On 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?

    #1091912
    Nico
    Member

    Hi 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,
    Nico

    #1092897
    dcantato
    Participant

    Much more elegant and sustainable than my editing of general.php, wouldn’t be bad to include in the next update somehow. Thanks again!

    #1093017
    Nico
    Member

    Glad 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

Viewing 6 posts - 1 through 6 (of 6 total)
  • The topic ‘Describe Miles after search result’ is closed to new replies.