Option for Events URL to link directly to website per event?

Home Forums Calendar Products Events Calendar PRO Option for Events URL to link directly to website per event?

Viewing 5 posts - 1 through 5 (of 5 total)
  • Author
    Posts
  • #1632804
    phylaxis
    Participant

    This is a great tip to add the ability for links in the calendar view to link directly to the event website, but this code does it for ALL events. Is there a way to add a per event option to do this?

    https://theeventscalendar.com/knowledgebase/make-links-event-go-straight-event-website/

    #1634940
    Brendan
    Keymaster

    Hi there,

    Thanks for emailing support.

    The only workaround I am aware of is using a plugin like Simple 301 Redirects and creating a redirect to the outside website when you create the event. This plugin is not supported by us, basically, you can use any 301 redirect plugin of your choosing.

    Let me know how that goes.

    Thanks,
    Brendan

    #1635426
    phylaxis
    Participant

    Ok. Thanks for the reply. I ended up implementing in a different way that worked for my situation. I’m posting my solution in case others find it helpful.

    I set up a flag on the tribe events custom post type using Advanced Custom Fields Pro and exposed that setting in the Event admin with ACF. I look for that flag and adjust the behavior in the calendar view template. I do this with an override in the tribe-events/month/single-event.php template in my custom theme.

    Here is the relevant code in case it might help someone else:

    At the top of the file I check for the ACF value and adjust the link variable accordingly:

    
    //see if we should link to the event website
    $link_to_event_website = get_post_meta( $post->ID, 'bdc-calendar-event-url', true );
    $event_website_url = tribe_get_event_meta( $post->ID, '_EventURL', true );
    if( $event_website_url &&  $link_to_event_website )
    {
    	$link = $event_website_url;
    }
    

    Later in the page this data is used to create the link.
    Please note in this example I’m also passing the some additional data that I built up earlier into the data-tribejson attribute to be used by the Javascript Templating System, but that’s not relevant to this example.

    
    //add additional data for pop-up
    $additional_data  = array(
       'eventCost'       => ltrim($event_cost, '$'),
       'eventStart'      => $event_start,
       'eventEnd'        => $event_end,
       'eventLocation'   => $event_location
    );
    ?>
    <div id="tribe-events-event-<?php echo esc_attr( $event_id ); ?>"<?php echo ( $event_style ); ?>class="<?php tribe_events_event_classes() ?>"  data-tribejson='<?php echo esc_attr( tribe_events_template_data( $post, $additional_data ) ); ?>'>
    	<h3 class="tribe-events-month-event-title"><a href="<?php echo esc_url( $link ) ?>" class="url"><?php echo $title ?></a></h3>
    </div><!-- #tribe-events-event-# -->
    
    #1635482
    Brendan
    Keymaster

    Awesome!

    Thanks for posting your solution.

    Brendan

    #1648081
    Support Droid
    Keymaster

    Hey 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

Viewing 5 posts - 1 through 5 (of 5 total)
  • The topic ‘Option for Events URL to link directly to website per event?’ is closed to new replies.