Make links to an event go straight to the Event Website URL

Have you ever input a URL in the "Event Website" field, and wished that when people clicked on that event from your calendar it took them straight to that website URL? This snippet will do just that. It will only swap the link out for events that have specified an Event Website URL, for all other events the usual event detail page is still shown.

The links will be replaced on our Event Views and in the navigation links at the bottom of single event pages. Please note that this snippet does not replace the link on Map View pins or Related Events.

To change the links, add this snippet to your functions.php file (minus the opening < ?php tag): 

Venue Link

To change the Venue Title Link on the single event template so that it goes to directly to the venue URL, you can add the following coding to the venue.php template in your child theme by following our themer's guide.

The template is located here:

the-events-calendar\src\views\modules\meta\venue.php

Once in your child theme, you want to replace this:

<?php echo tribe_get_venue() ?>

With this coding:

<?php
	$event_id = get_the_id();
	$venue_url = tribe_get_event_meta( tribe_get_venue_id( $event_id ), '_VenueURL', true );
    $venue_name = get_the_title( tribe_get_venue_id( $event_id  ) );
    if ( $venue_url ) {
        echo '<a href="' . esc_url( $venue_url ) . '">' . esc_html( $venue_name ) . '</a>';
    } else {
        echo esc_html( $venue_name );
    }
?>

Organizer Link

To change the Organizer Title Link on the single event template so that it goes to directly to the organizer URL, you can add the following coding to the organizer.php template in your child theme by following our themer's guide.

The template is located here:

the-events-calendar\src\views\modules\meta\organizer.php
Once in your child theme, you want to replace this:

<?php echo tribe_get_organizer( $organizer ) ?>

With This Coding:

<?php
    $organize_website = tribe_get_event_meta( $organizer, '_OrganizerWebsite', true );
    $organizer_name = get_the_title( $organizer );
    if ( $organize_website ) {
        echo '<a href="' . esc_url( $organize_website ) . '">' . esc_html( $organizer_name ) . '</a>';
    } else {
        echo esc_html( $organizer_name );
    }
?>

And you should be all set. Now when you have an organizer website when clicking on their name it will go to their website and not the single organizer.