• Resolved cannedgeek

    (@cannedgeek)


    I am trying to implement the customization in this post:
    https://theeventscalendar.com/knowledgebase/make-links-event-go-straight-event-website/

    So I go into Appearance/Editor and bring up the functions.php file and insert the following code as found in the above link:
    /*
    * This changes the event link to the event website URL if that is set.
    * NOTE: Comment out the add_filter() line to disable this function.
    */
    function tribe_set_link_website ( $link, $postId ) {
    $website_url = tribe_get_event_website_url( $postId );
    // Only swaps link if set
    if ( !empty( $website_url ) ) {
    $link = $website_url;
    }
    return $link;
    }
    add_filter( 'tribe_get_event_link', 'tribe_set_link_website', 100, 2 );

    But doing so completely breaks the site. Like, visiting my website just produces a single line of text: error in line 191 of functions.php. Luckily I can just restore a backup copy of functions.php and it’s all good. Is there a termination line I’m missing here? The document makes it sounds like it’s a simple copy/paste, but it seems I’m missing a vital step here. Thanks in advance.

    https://www.ads-software.com/plugins/the-events-calendar/

Viewing 6 replies - 1 through 6 (of 6 total)
  • Hi there!

    Thanks for getting in touch–and so sorry you had to experience such a scary incident, yikes!

    In testing the snippet as you’ve written it here, everything appears to work fine on my test site, so I don’t believe the problem is with the snippet itself. As long as you’re pasting the code onto a new line in your functions.php file (i.e. not inside another bit of code), somewhere between the leading <?php at the beginning of the document and the closing ?> at the end, you should be fine. If you want to be doubly sure, I’d back up your functions.php file and try inserting the snippet again, directly above the closing ?> to ensure it’s not interfering with any other functions. If your site malfunctions again after this change, you can simply roll it back to your backup, no harm done.

    Failing that, can you confirm that your WordPress install and your version of The Events Calendar are both up-to-date? If so, I’d suggest running through our conflict testing guide as a next step, to eliminate the possibility that a theme or plugin conflict might be introducing issues!

    Let me know what you find out, and we’ll go from there! ?? Thanks!

    Thread Starter cannedgeek

    (@cannedgeek)

    Sweet. Nestled the code just under the <?php at the start of the document and that did the trick. Thanks!

    Thread Starter cannedgeek

    (@cannedgeek)

    Uh wait, here’s an odd quirk. When I go to mysite.com/wp-login.php the login is busted with the following text up top.

    Warning: Cannot modify header information - headers already sent by (output started at /home/cannedgeek/cannedgeek.com/wp-content/themes/maker/functions.php:5) in /home/cannedgeek/cannedgeek.com/wp-login.php on line 390
    
    Warning: Cannot modify header information - headers already sent by (output started at /home/cannedgeek/cannedgeek.com/wp-content/themes/maker/functions.php:5) in /home/cannedgeek/cannedgeek.com/wp-login.php on line 403
    Canned Geek

    But strangely I can go to an existing logged in page like mysite.com/wp-admin/post.php?post=762&action=edit and move around the back end no worries.

    Thread Starter cannedgeek

    (@cannedgeek)

    OK update number 3! Think I got it figured, it doesn’t like any empty lines.

    So this

    will crash

    But this
    is fine.

    Hey, thanks for following up–thrilled to hear you’ve gotten things working now! ??

    I’m going to go ahead and mark this thread as resolved for now, but please don’t hesitate to follow up if you should have any other issues, or feel free to start a new thread for any new issues that might crop up!

    Thread Starter cannedgeek

    (@cannedgeek)

    Thanks. OK so now the name of the event and the “Find out more” link both direct to the website. I’d like to make a slight change either by:

    A) Making the “Find out more” link go to the individual event listing

    or

    B) Is there another way to have the website link be visible in list view?

    Reason being is there’s usual information in the individual listing (like tags) and I’d like users to be able to see – but I also want to give them easy access to the events’ website.

Viewing 6 replies - 1 through 6 (of 6 total)
  • The topic ‘Making event links go direct to event website’ is closed to new replies.