Home › Forums › Calendar Products › Events Calendar PRO › Next & previous event link on single event
- This topic has 6 replies, 4 voices, and was last updated 9 years, 1 month ago by
Chloe.
-
AuthorPosts
-
February 20, 2017 at 6:42 am #1242130
Chloe
ParticipantHi,
I would like the next and previous event links on my single event, to only target events from the same category of the current single event. Would you know a way to do this ?Thanks in advance,
Best,
February 20, 2017 at 10:12 pm #1242708Cliff
MemberHi, Jeremy.
Would you please link to your site where you’d like this to be in effect and also link to where you’d like it to go (e.g. linking to another category)?
If you share an annotated screenshot or video screen capture, it might help communicate what you’re seeing and what exactly the request is.
February 20, 2017 at 10:17 pm #1242713Cliff
MemberRereading your request, I think you might be looking for this: tribe_get_related_posts(), which can be customized via the tribe_related_posts_args filter.
You can see this code snippet for a possible starter template to your own customization:
https://gist.github.com/elimn/1e6797dd1a5d8ee666c5
If I’m not mistaken, the Related Events already looks for events within the same Event Category.
Please let me know if you have any follow-up questions on this topic.
February 21, 2017 at 12:08 am #1242781Chloe
ParticipantHi Cliff,
Thanks for your answers, to answer your first post :
If you look at this single event for exemple :http://www.crformation.fr/formations/formation-buraliste-continue-limoges/
you will see on top & bottom of the page the .tribe-events-sub-nav : both linking to the previous and next event, chronnologically, but regardless of the event’s category. What I’m trying to do is to set up these specific links to target the next & previous events from the same category of the event displayed.I think I need to modify something in the function > links.php file but I don’t know what & where to add it
/** * Link to Previous Event (Display) * * Displays a link to the previous post by start date for the given event * * @param bool|string $anchor link text. Use %title% to place the post title in your string. * * @see tribe_get_prev_event_link() */ function tribe_the_prev_event_link( $anchor = false ) { echo apply_filters( 'tribe_the_prev_event_link', tribe_get_prev_event_link( $anchor ) ); } /** * Return a link to the previous post by start date for the given event * * @param bool|string $anchor link text. Use %title% to place the post title in your string. * * @return string */ function tribe_get_prev_event_link( $anchor = false ) { global $post; return apply_filters( 'tribe_get_prev_event_link', Tribe__Events__Main::instance()->get_event_link( $post, 'previous', $anchor ) ); } /** * Link to Next Event (Display) * * Display a link to the next post by start date for the given event * * @param bool|string $anchor link text. Use %title% to place the post title in your string. * * @return void * @see tribe_get_next_event_link() */ function tribe_the_next_event_link( $anchor = false ) { echo apply_filters( 'tribe_the_next_event_link', tribe_get_next_event_link( $anchor ) ); } /** * Return a link to the next post by start date for the given event * * @param bool|string $anchor link text. Use %title% to place the post title in your string. * * @return string */ function tribe_get_next_event_link( $anchor = false ) { global $post; return apply_filters( 'tribe_get_next_event_link', Tribe__Events__Main::instance()->get_event_link( $post, 'next', $anchor ) ); } /** * Get a link to the previous events * * @return string */ function tribe_get_previous_events_link() { $link = ''; if ( tribe_is_upcoming() && ( ! empty ( $_REQUEST['tribe_paged'] ) && $_REQUEST['tribe_paged'] > 1 ) ) { // if we're more than one page into the future, the previous link will be in the future as well $link = tribe_get_upcoming_link(); } else { $link = tribe_get_past_link(); } return apply_filters( 'tribe_get_previous_events_link', $link ); } /** * Get a link to the next events * * @return string */ function tribe_get_next_events_link() { $link = ''; if ( tribe_is_past() && ( ! empty ( $_REQUEST['tribe_paged'] ) && $_REQUEST['tribe_paged'] > 1 ) ) { // if we're more than one page into the past, the next link will be in the past as well $link = tribe_get_past_link(); } else { $link = tribe_get_upcoming_link(); } return apply_filters( 'tribe_get_next_events_link', $link ); }Thanks,
February 21, 2017 at 12:10 pm #1243249Cliff
MemberThose might be functions for you to use but you shouldn’t ever modify them.
Best practice for adding custom code (like to implement a PHP snippet to modify The Events Calendar) is to create a functionality plugin, unless it’s something specific to your theme, in which case best practice is to make sure you’re using a child theme, then add the customization to your child theme’s functions.php file.
You should also reference https://theeventscalendar.com/tips-working-wordpress-actions-filters/ to learn how to get started with customizing.
I hope this information helps!
If you need some coding help, you may want to ask your developer or reference our documentation and list of known customizers.
March 15, 2017 at 9:35 am #1254546Support Droid
KeymasterHey there! This thread has been pretty quiet for the last three weeks, so we’re going to go ahead and close it to avoid confusion with other topics. If you’re still looking for help with this, please do open a new thread, reference this one and we’d be more than happy to continue the conversation over there.
Thanks so much!
The Events Calendar Support Team -
AuthorPosts
- The topic ‘Next & previous event link on single event’ is closed to new replies.
