Home › Forums › Calendar Products › Events Calendar PRO › Event List: Upcoming events shows venu URL instead of name
- This topic has 10 replies, 2 voices, and was last updated 11 years, 1 month ago by
Geoff.
-
AuthorPosts
-
March 12, 2015 at 10:00 am #947921
Riza
ParticipantI 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?
March 12, 2015 at 2:29 pm #948001Geoff
MemberHello 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!
GeoffMarch 13, 2015 at 3:07 am #948096Riza
ParticipantLet’s try again if the link will stay inserted.
March 13, 2015 at 8:13 am #948147Geoff
MemberThanks 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!
GeoffMarch 14, 2015 at 11:02 am #948338Riza
ParticipantWhat happens if you remove the snippet? Does the Venue Name show up properly?
Yes
March 16, 2015 at 7:54 am #948556Geoff
MemberHi 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!
GeoffMarch 16, 2015 at 8:03 am #948558Riza
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?
March 16, 2015 at 8:10 am #948561Riza
ParticipantFYI, 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 );March 16, 2015 at 8:35 am #948572Geoff
MemberI 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
March 16, 2015 at 9:51 am #948595Riza
ParticipantThat did it. Thank you very much.
Your support is examplrary 🙂
March 16, 2015 at 9:55 am #948599Geoff
MemberMy pleasure! I’m so glad that worked out. Thanks for following up and for the kind words as well. 🙂
Cheers!
Geoff -
AuthorPosts
- The topic ‘Event List: Upcoming events shows venu URL instead of name’ is closed to new replies.
