Home › Forums › Calendar Products › Events Calendar PRO › Option for Events URL to link directly to website per event?
- This topic has 3 replies, 2 voices, and was last updated 5 years, 7 months ago by Brendan.
-
AuthorPosts
-
September 27, 2018 at 5:36 pm #1632804phylaxisParticipant
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/
October 1, 2018 at 3:52 pm #1634940BrendanKeymasterHi 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,
BrendanOctober 2, 2018 at 8:37 am #1635426phylaxisParticipantOk. 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 thedata-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-# -->
October 2, 2018 at 9:27 am #1635482BrendanKeymasterAwesome!
Thanks for posting your solution.
Brendan
October 24, 2018 at 9:35 am #1648081Support DroidKeymasterHey 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 -
AuthorPosts
- The topic ‘Option for Events URL to link directly to website per event?’ is closed to new replies.