Event List: Upcoming events shows venu URL instead of name

Home Forums Calendar Products Events Calendar PRO Event List: Upcoming events shows venu URL instead of name

Viewing 11 posts - 1 through 11 (of 11 total)
  • Author
    Posts
  • #947921
    Riza
    Participant

    I have modified EC as suggested on the following thread.

    Wether after the modification or not related to it, I’m not sure, the ‘Event List: Upcoming events’ widget shows the venu URL instead of the venu name when venue is selected on the wisget options. See the widget on the home page.

    How can I make it show the venue name?

    #948001
    Geoff
    Member

    Hello Riza! Nice to see you again. 🙂

    Will you please post the link to the thread you referenced? It doesn’t look like it came through when you published the thread and that would help give me more context for what you[re working with.

    In general, if the Venue URL is printing instead of the Venue Name, you should be able to dig into the code you modified and use tribe_get_venue() to explicitly return the Venue Name.

    Cheers!
    Geoff

    #948096
    Riza
    Participant

    Let’s try again if the link will stay inserted.

    Override venue link with custom URL?

    #948147
    Geoff
    Member

    Thanks for the URL! That’s super helpful.

    Did the Venue Name display correctly in the widget with the snippet, then stopped working. Or did it always display the URL when you used the snippet?

    What happens if you remove the snippet? Does the Venue Name show up properly?

    Thanks!
    Geoff

    #948338
    Riza
    Participant

    What happens if you remove the snippet? Does the Venue Name show up properly?

    Yes

    #948556
    Geoff
    Member

    Hi there, Riza!

    I bet that’s because the snippet targets all events, regardless of what context they are in. Please try wrapping the Venue and Organizer functions in a conditional statement that only targets the Single Event View:

    // Single Events
    if ( tribe_is_event() && is_single() ) {
    // Rest of snippet
    }

    Cheers!
    Geoff

    #948558
    Riza
    Participant
    /*
    * This changes the venue link to the venue website URL if that is set.
    * NOTE: Uncomment the add_filter() line to enable this function.
    */
    // Single Events
    if ( tribe_is_event() && is_single() ) {
    // Rest of snippet
    function tribe_set_venue_website ( $link, $postId, $display, $venue_url ) {
    $venue_link = tribe_get_venue_website_link( tribe_get_venue_id( $postId ) );
    // Only swaps link if set and full HTML <a> link is set
    if ( !empty( $venue_link ) ) {
    if ( $display ) {
    $link = $venue_link;
    } else {
    $venue_url = tribe_get_event_meta( tribe_get_venue_id( $postId ), '_VenueURL', true );
    $parseUrl = parse_url( $venue_url );
    if ( empty( $parseUrl['scheme'] ) ) {
    $venue_url = "http://$venue_url";
    }
    $link = $venue_url;
    }
    }
    return $link;
    }
    add_filter( 'tribe_get_venue_link', 'tribe_set_venue_website', 100, 4 ); 
    }

    Above broke the site. My PHP is VERY bad, may I ask you to see if I have done a syntax error?

    #948561
    Riza
    Participant

    FYI, the original code that works is also below:

    /*
    * This changes the venue link to the venue website URL if that is set.
    * NOTE: Uncomment the add_filter() line to enable this function.
    */
    function tribe_set_venue_website ( $link, $postId, $display, $venue_url ) {
    $venue_link = tribe_get_venue_website_link( tribe_get_venue_id( $postId ) );
    // Only swaps link if set and full HTML <a> link is set
    if ( !empty( $venue_link ) ) {
    if ( $display ) {
    $link = $venue_link;
    } else {
    $venue_url = tribe_get_event_meta( tribe_get_venue_id( $postId ), '_VenueURL', true );
    $parseUrl = parse_url( $venue_url );
    if ( empty( $parseUrl['scheme'] ) ) {
    $venue_url = "http://$venue_url";
    }
    $link = $venue_url;
    }
    }
    return $link;
    }
    add_filter( 'tribe_get_venue_link', 'tribe_set_venue_website', 100, 4 ); 
    
    #948572
    Geoff
    Member

    I think you will need to add one more closing bracket before $link is returned. This seems to work on my setup:

    https://gist.github.com/geoffgraham/fed6c0596e77202e0f52

    Let me know if that helps!

    Geoff

    #948595
    Riza
    Participant

    That did it. Thank you very much.

    Your support is examplrary 🙂

    #948599
    Geoff
    Member

    My pleasure! I’m so glad that worked out. Thanks for following up and for the kind words as well. 🙂

    Cheers!
    Geoff

Viewing 11 posts - 1 through 11 (of 11 total)
  • The topic ‘Event List: Upcoming events shows venu URL instead of name’ is closed to new replies.