Home › Forums › Calendar Products › Events Calendar PRO › Previous & Next event links with thumbnails
- This topic has 4 replies, 3 voices, and was last updated 9 years, 10 months ago by
darrienw93.
-
AuthorPosts
-
June 16, 2016 at 9:10 am #1127931
darrienw93
ParticipantHi,
I am trying to create “Previous” and “Next” event links on my single-event.php page, but I also want to grab the thumbnails of the events.
I know that there are two functions that grab the links but they do not grab the thumbnails.
<?php tribe_the_prev_event_link( '%title%' ) ?> <?php tribe_the_next_event_link( '%title%' ) ?>I tried working with the get_adjacent_post function but it does not return anything when used.
<?php $prev_post = get_adjacent_post( true, '', true); ?> <?php if ( is_a( $prev_post, 'WP_Post' ) ) { ?> <a href="<?php echo get_permalink( $prev_post->ID ); ?>"> <?php echo tribe_event_featured_image( $prev_post->ID, 'medium', false ); ?> <div class="content"><?php echo get_the_title( $prev_post->ID ); ?></div> </a> <?php } ?>Any help would be greatly appreciated!
-
This topic was modified 9 years, 10 months ago by
darrienw93.
June 16, 2016 at 10:32 am #1128024George
ParticipantHey there,
We unfortunately cannot help with code customizations, so you’ll have to take the reins on refining this, making iWe unfortunately cannot help with code customizationst work with your design, etc, but here’s an example of two snippets I wrote for you to achieve this ? https://git.io/voE7Q
Here’s a screenshot of this to prove that it works:
As noted, you’ll need to take the reins on further refinement, but I hope this helps!
Your code is close, but the tricky thing with events is that the “previous” and “next” events only have these relationships to the “currently-viewed” event based on the time and date the event will occur. WordPress does not have support for events out-of-the-box (hence the existence of our plugins!), and is not built for that, so when you use its built-in features for getting adjacent posts, the relationship of “next” or “previous” is based on the date the post was published—quite different than the relationships of events!
So, as you can see in the snippet I shared with you, some custom class methods within The Events Calendar need to be used here.
Tinker around with it, and let me know if there’s anything else I can try to help with.
Cheers!
GeorgeJune 16, 2016 at 11:09 am #1128046darrienw93
ParticipantHey George,
Your snippet was perfect!!!
Thank you very much for you quick help!
-
This reply was modified 9 years, 10 months ago by
darrienw93.
June 16, 2016 at 1:22 pm #1128139George
Participant😀
-
This topic was modified 9 years, 10 months ago by
-
AuthorPosts
- The topic ‘Previous & Next event links with thumbnails’ is closed to new replies.

