The Events Calendar URL

Home Forums Calendar Products Community Events The Events Calendar URL

Viewing 6 posts - 1 through 6 (of 6 total)
  • Author
    Posts
  • #1077549
    Daniel Maier
    Participant

    Hello,

    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.
    #1077782
    Josh
    Participant

    Hey 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!

    #1078078
    Daniel Maier
    Participant

    Hi 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.

    #1078095
    Daniel Maier
    Participant

    Sorry 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>
    
    #1078294
    Daniel Maier
    Participant

    I 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.
    #1078714
    Josh
    Participant

    Hey 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!

Viewing 6 posts - 1 through 6 (of 6 total)
  • The topic ‘The Events Calendar URL’ is closed to new replies.