Home › Forums › Calendar Products › Community Events › The Events Calendar URL
- This topic has 5 replies, 2 voices, and was last updated 10 years, 1 month ago by
Josh.
-
AuthorPosts
-
February 18, 2016 at 3:04 pm #1077549
Daniel Maier
ParticipantHello,
Is there a function that I can use to dynamically get the Events Calendar main URL that has been setup in settings (slug)?
I want to use this dynamic URL in a page template and in case the event calendar URL gets changed later on the template will not need to be changed as well.
Basically I just need a function to get the events url. Mine is currently setup to /events/. So the function should return http://mydomain.com/events/.
I checked your code and you use the following for that:
esc_url( Tribe__Events__Main::instance()->getLink() );
Do you have anything I could use in a WordPress page template?
Thanks.
-
This topic was modified 10 years, 1 month ago by
Daniel Maier.
-
This topic was modified 10 years, 1 month ago by
Daniel Maier.
February 18, 2016 at 10:05 pm #1077782Josh
ParticipantHey Daniel,
You could use that same example when getting the events link. It would look something like:
https://gist.github.com/BeardedGinger/15cb3a3dd5d6ea47b0ef
Let me know if this helps.
Thanks!
February 19, 2016 at 7:48 am #1078078Daniel Maier
ParticipantHi Josh,
Thanks for helping. However, that did not work. I get an empty result:
<a href="">more events ›</a>Using the following code you provided:
<?php if( class_exists( 'Tribe__Events__Main' ) ) { $link = esc_url( Tribe__Events__Main::instance()->getLink() ); } echo '<a href="'.$link.'">Events</a>'; ?> <a href="<?php '.$link.' ?>">more events ›</a>Do I need to include/include_once any global function on my template for this to see the events functions?
Thank you.
February 19, 2016 at 7:56 am #1078095Daniel Maier
ParticipantSorry Josh, I had a wrong syntax. It is working now! Thank you.
if( class_exists( 'Tribe__Events__Main' ) ) { $link = esc_url( Tribe__Events__Main::instance()->getLink() ); } echo '<a href="'.$link.'">Events</a>'; ?> <a href="<?php echo $link; ?>">more events ›</a>February 19, 2016 at 9:17 am #1078294Daniel Maier
ParticipantI just found out that the Events Calendar has the following function: tribe_get_events_link(). This can also be used:
<?php echo esc_url( tribe_get_events_link() ); ?>-
This reply was modified 10 years, 1 month ago by
Daniel Maier.
February 19, 2016 at 10:32 pm #1078714Josh
ParticipantHey Daniel,
Awesome, I’m glad you were able to get something useful here. And that function works as well (most likely a better solution since the function should persist even if class names change again in the future).
I’ll go ahead and close this thread for now. If you have any further questions, please don’t hesitate to open a new one.
Thanks!
-
This topic was modified 10 years, 1 month ago by
-
AuthorPosts
- The topic ‘The Events Calendar URL’ is closed to new replies.
