• Resolved kdelsimone

    (@kdelsimone)


    Hello,

    I am using this snippet (found here) to make events go to straight to the event website url:

    function tribe_set_link_website ( $link, $postId ) {
    	$website_url = tribe_get_event_website_url( $postId );
    	// Only swaps link if set
    	if ( !empty( $website_url ) ) {
    		$link = $website_url;
    	}
    	return $link;
    }
    add_filter( 'tribe_get_event_link', 'tribe_set_link_website', 100, 2 );

    Works great.

    I’d also like that url to open in a new tab/page as (discussed here), where the following code is offered:

    add_filter( 'tribe_get_event_website_link_target', 'blank_target_for_new_window' );
    
    function blank_target_for_new_window() {
    	return '_blank';
    }

    This on its own works fine, but since the first snippet above bypasses the single event view by redirecting to the event website url, understandably it doesn’t work when combined with the first snippet.

    I’ve tried modifying the latter snippet (the one to open in a new tab/window) every which way I can think of to play nicely with the former (redirecting to the event website url), with no luck. It seems there should be an easy enough solution; obviously I’m missing something.

    Anyone have any ideas/suggestions?

Viewing 3 replies - 1 through 3 (of 3 total)
  • Hey there,

    Thanks for reaching out 😄

    I would modify the template files here. Specifically:

    single-event.php file from the-events-calendar/src/views/month and paste it to [your-theme]/tribe-events/month/single-event.php — then manually add a target=”_blank” to the event link.

    Since you are filtering this URL, you may want to direct it straight to the event website if the filter gives you trouble ► echo tribe_get_event_meta( get_the_ID(), '_EventURL', true );

    Our Themer’s Guide can help you get familiar with overrides.

    Take care,
    Ed 🤟

    Thread Starter kdelsimone

    (@kdelsimone)

    Thanks for your help, Ed.

    I’m a little confused. Where exactly do you suggest I manually add a target=”_blank” to?

    Thread Starter kdelsimone

    (@kdelsimone)

    Figured it out. Thanks again, Ed!

Viewing 3 replies - 1 through 3 (of 3 total)
  • The topic ‘Opening the event website url in a new tab/window’ is closed to new replies.