Home › Forums › Calendar Products › Event Aggregator › Import and show facebook eventlink in description
- This topic has 7 replies, 2 voices, and was last updated 10 years, 1 month ago by
George.
-
AuthorPosts
-
March 9, 2016 at 3:56 pm #1086900
Tobias
ParticipantHi,
is it possible to add the eventlink as the ‘Event Link’ in the description?
thx!
March 10, 2016 at 8:28 am #1087194George
ParticipantHey Tobias,
It’s unfortunately not easily possible to do this selectively, but I did write a snippet of code here for you that should help quite a bit—this will make events imported from Facebook link directly to the Facebook event on facebook.com.
If the event is NOT imported from Facebook, it will just link to its normal single-event page on your site.
Try adding this code to your theme’s functions.php file and let me know if it helps!
add_filter( 'tribe_get_event_link', 'tribe_maybe_make_permalinks_fb_links', 10, 3 );function tribe_maybe_make_permalinks_fb_links( $link, $postId, $full_link ) {
$event_id = 0;
if ( $postId instanceof WP_Post ) {
$event_id = absint( $postId->ID );
}$event_id = ( ! $event_id ? get_the_ID() : $event_id );
$meta = get_post_meta( $event_id );if ( ! isset( $meta['_EventOrigin'][0] ) || 'facebook-importer' !== $meta['_EventOrigin'][0] )
return $link;if ( empty( $meta['_FacebookID'][0] ) )
return $link;return sprintf( 'http://www.facebook.com/events/%s', absint( $meta['_FacebookID'][0] ) );
}
March 11, 2016 at 2:22 am #1087637Tobias
ParticipantHi George,
thx for your help.
There might be an issue within that line:
if ( $postId instanceof WP_Post ) {
$event_id = absint( $postId->ID );
}
Got it working, though. But there might be a missunderständing.
What it does right now, is linking directly to facebook, if it is an import.
What I want to have, is just a link shown in the description, so the user can go
to facebook and join the event. Like that (“Website:”):
http://www.club-kreuzkeller.de/wordpress/event/the-awakening-2/I have to do that manually, atm.
Thx,
Tobi
March 11, 2016 at 11:31 am #1087871George
ParticipantHi Tobi,
If you tweak the code I shared to this, it will add a “View on Facebook” link after event description content with a link to the event on Facebook:
add_filter( 'the_content', 'tribe_auto_add_FB_link_after_content' );function tribe_auto_add_FB_link_after_content( $content ) {
if ( ! tribe_is_event() )
return $content;$meta = get_post_meta( get_the_ID() );
if ( ! isset( $meta['_EventOrigin'][0] ) || 'facebook-importer' !== $meta['_EventOrigin'][0] )
return $content;if ( empty( $meta['_FacebookID'][0] ) )
return $content;return $content . sprintf( '
View on Facebook', absint( $meta['_FacebookID'][0] ) );
}This will not add the link in Month View tooltips, for example, or on excerpts—only after single-event descriptions. If you would like to add the link to those other locations, that is unfortunately a more complicated customization and is too far outside the scope of our support for further code-customizing assistance.
I hope this all helps regardless, and wish you the best of luck with your code customizing!
Cheers,
GeorgeMarch 16, 2016 at 2:31 am #1089563Tobias
ParticipantHi George,
thx for your help. Sorry for bothering you again… I definitely understand when this runs out of the regular support.
I give it another try, though 🙂
Your Code gives back the ‘View on Facebook’, but no link, not even hidden in some wrong html.
meta[‘_FacebookID’][0] gives back the Event-ID, but couldn’t get i working anyway, since the whole thing is somehow too large for me.
Somehow or other, the whole thing might be needed by more useres, to make clients go to facebook and join the events.
Maybe a new Version-Feature..?Thx,
TobiasMarch 17, 2016 at 7:38 am #1090257George
ParticipantHi Tobias,
Thanks for reaching out. One thing I noticed here is that the support forum’s security features here have stripped some of the characters in my original code!
So, if you copied and pasted the code from these forums into your site, that is why the “view on Facebook” link might be working.
Instead of using the code on this forum thread, I have pasted the ACCURATE and COMPLETE code into a Gist here → https://git.io/vawLa
Get rid of the original code you copied from this thread; and instead, replace it with the code from that Gist.
That might help!
Cheers,
GeorgeMarch 20, 2016 at 10:25 am #1091553Tobias
ParticipantThx George,
works perfect!
Cheers – Tobi
March 20, 2016 at 1:03 pm #1091582George
ParticipantGlad to hear it—best of luck with your project!
Sincerely,
George -
AuthorPosts
- The topic ‘Import and show facebook eventlink in description’ is closed to new replies.
