Previous & Next event links with thumbnails

Home Forums Calendar Products Events Calendar PRO Previous & Next event links with thumbnails

Viewing 4 posts - 1 through 4 (of 4 total)
  • Author
    Posts
  • #1127931
    darrienw93
    Participant

    Hi,

    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.
    #1128024
    George
    Participant

    Hey 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!
    George

    #1128046
    darrienw93
    Participant

    Hey George,

    Your snippet was perfect!!!

    Thank you very much for you quick help!

    • This reply was modified 9 years, 10 months ago by darrienw93.
    #1128139
    George
    Participant

    😀

Viewing 4 posts - 1 through 4 (of 4 total)
  • The topic ‘Previous & Next event links with thumbnails’ is closed to new replies.