Upcoming and past events on single venue page

Home Forums Calendar Products Events Calendar PRO Upcoming and past events on single venue page

Viewing 4 posts - 1 through 4 (of 4 total)
  • Author
    Posts
  • #939757
    sabinevi
    Participant

    I would like to show both upcoming and past events but only on the single venue page. I have overridden the single-venue.php template in /wp-content/mytheme/tribe-events/pro/ and found this at the bottom of the script:

    <?php echo tribe_include_view_list( array('venue' => $venue_id, 'eventDisplay' => 'upcoming', 'posts_per_page' => apply_filters( 'tribe_events_single_venue_posts_per_page', 100 ) ) )?>

    So I copied it and pasted it below this line, I only changed the 'upcoming' to 'past'. Unfortunately this gave me a page without any events. I tried the wp_reset_postdata(); in between the two lines but that didn’t solve it. It’s either upcoming or past events, not both.

    Searching further on this forum, I found this thread which could be a solution but a lot more work.
    Is there a way to use the tribe_include_view_list function (or a similar function) twice in one page?

    A link to the documentation of this function would be useful too since I can’t find it in in your functions documentation.

    #940161
    Brook
    Participant

    Howdy Sabinevi,

    That’s an interesting idea. It should be doable. I have a snippet here that sets the default date of the calendar views. So if you visit the default page, usually domain.com/events/ the default date is today. So in list view it shows all events from today forward. However, you can change this to any arbitrary date. If we change it to a past date then all events will show up, starting with the first one.

    https://gist.github.com/elimn/d034dfddb9be206d9cc1

    You could modify this snippet using this function as an extra conditional, to make it apply only to venues: https://theeventscalendar.com/function/tribe_is_venue/

    Does that all make sense? Would that solution work? Please let me know.

    Cheers!

    – Brook

    #940842
    sabinevi
    Participant

    Hi Brook,

    Thanks for your solution. I think I must have omitted a semi-colon or comma in my initial code because I managed to get it to work.
    For those of you who come here looking for answers, this is the code I used in the overridden single-venu.php:

    	do_action('tribe_events_single_venue_before_upcoming_events') 
    	// First show upcoming events
    	echo tribe_include_view_list( array(
    		'venue'          => $venue_id,
    		'eventDisplay'   => 'upcoming',
    		'posts_per_page' => apply_filters( 'tribe_events_single_venue_posts_per_page', 100 )
    	) );
    	// and then those from the past
    	wp_reset_postdata(); 
    	echo tribe_include_view_list( array(
    		'venue'          => $venue_id,
    		'eventDisplay'   => 'past',
    		'posts_per_page' => apply_filters( 'tribe_events_single_venue_posts_per_page', 100 )
    	) );
    	do_action('tribe_events_single_venue_after_upcoming_events');
    #941105
    Brook
    Participant

    Excellent! I am happy to hear you got it working exactly as you wanted. Cheers!

    – Brook

Viewing 4 posts - 1 through 4 (of 4 total)
  • The topic ‘Upcoming and past events on single venue page’ is closed to new replies.