Help Desk

Redirect specific events to custom pages

  • Posts: 44 Topics: 12
    | Permalink

    Most of our events are fine and work normally, but a few of them require a specific set of content that can’t easily be achieved with the standard event post template, and therefore have their own pages set up based on custom templates. Is there any way that, when a user clicks on the event title for these specific events, they can be redirected to the custom page in question, rather than the event post?

    Posts: 2589
    | Permalink

    Hi Raymond,

    I think your best bet here would be to edit the templates for the views that you are using. You can do this by following the instructions in our themer’s guide. So for example, if you wanted to edit the link to the single event in month view, you would want to edit the template found at wp-content/plugins/src/views/month/single-event.php. There, you will find a $link variable that is storing the link to the single event, and the following line, where the link is being output (line 196):

    <h3 class="tribe-events-month-event-title"><a href="<?php echo esc_url( $link ) ?>" class="url"><?php echo $title ?></a></h3>

    After you’ve copied this template into your child theme (following the instructions in our themer’s guide), you can edit the link there.

    We are a bit limited in the amount of support that we can provide for customizations, but if you get stuck or have any questions, please let me know. I will be happy to point you in the right direction!

    Thanks,

    Jennifer

    Posts: 44 Topics: 12
    | Permalink

    Hello,

    Thanks for the update, that makes sense. So in theory, we could, for example, wrap this in an if statement that produced a different type of link based on the category in question? If so, do you know which variable we can use to determine the category type?

    Posts: 2589
    | Permalink

    Sure thing! You can use the tribe_event_in_category function to check if an event has a certain category. Our functions list has several other functions like this, so I would definitely recommend this as a resource when customizing our plugins.

    Posts: 44 Topics: 12
    | Permalink

    Thanks!

    Posts: 44 Topics: 12
    | Permalink

    Hi again,

    I have almost got this sorted. However, I can’t find the template that links the image of photo mode through to the event post. I have looked in photo/single-event.php but even when I remove the link from that entirely I still have the image linking through to the event post. Should I be looking somewhere else?

    This is all based on photo mode BTW (probably should have said that sooner!)

    Posts: 2589
    | Permalink

    Hi Raymond,

    Thanks for clarifying that you’re using photo view! You can remove the link from the image by changing this line in the photo/single-event.php file:

    <!--?php echo tribe_event_featured_image( null, 'medium' ); ?-->

    to

    <!--?php echo tribe_event_featured_image( null, 'medium', false ); ?-->

    If you want to change the link for the image, you can use the tribe_event_featured_image_link filter (see the tribe_event_featured_image function in – line 920 – in wp-content/plugins/the-events-calendar/src/functions/template-tags/general.php).

    Let me know if this helps!

    Posts: 44 Topics: 12
    | Permalink

    Ah great thanks, I think I found the filter I need:

        if ( ! empty( $featured_image ) &amp;&amp; apply_filters( 'tribe_event_featured_image_link', $link ) ) {
            $featured_image = '<a href="' . esc_url( tribe_get_event_link( $post_id ) ) . '">' . $featured_image . '</a>';
        }
    

    Do I add this to functions.php to override the copy in the plugin folder?

    Posts: 44 Topics: 12
    | Permalink

    It’s OK, I got it sorted – I disabled the link and wrapped the whole div in the link I was using for the title – works fine now, thanks.

    Posts: 2589
    | Permalink

    Great, I’m glad to hear it’s working now!

    If there’s anything else that I can help with, please let me know 🙂

You must be logged in and hold an active support license to create new topics in the help desk. Please visit our products store to purchase a license.

Subscribe to Updates