Home › Forums › Calendar Products › Events Calendar PRO › List Upcoming & Past Events at /events
- This topic has 4 replies, 2 voices, and was last updated 9 years, 7 months ago by Barry.
-
AuthorPosts
-
July 24, 2014 at 4:18 am #495565David KellyParticipant
Is there any way to include past events, along with upcoming events on the main Events page (/events)?
At the moment visiting “/events” shows the one upcoming event scheduled, along with a link to “Previous Events”. I would like that page to display past events under any scheduled upcoming events (as with a normal loop).
Thanks,
David
July 25, 2014 at 7:30 am #506149BarryMemberHi David,
Though a bit rough and ready this snippet (which you could for instance add to your theme’s functions.php file) should give you an idea as to how you might approach this:
add_action( 'tribe_events_after_loop', 'add_past_events' ); function add_past_events() { if ( ! tribe_is_list_view() || ! tribe_is_upcoming() ) return; remove_action( 'tribe_events_after_loop', 'add_past_events' ); $past_events = tribe_get_events( array( 'eventDisplay' => 'past' ) ); foreach ( $past_events as $event ) echo "$event->post_title - $event->EventStartDate <br/>"; }
Does that help at all?
July 28, 2014 at 2:17 am #523613David KellyParticipantThanks Barry,
That gets me a little closer, but it’s causing an issue with the “Previous Events” pagination link at the bottom of the page – when I click on that, the past events (created in $past_events) are repeated.
Is there any way to display both upcoming & past events in the same loop? I will need to do the same thing for the Event Categories too.
Thanks,
David
July 28, 2014 at 12:52 pm #527453BarryMemberHi David!
That was really just a starting point – you might tweak and further build on it and use helpers like tribe_is_past() to avoid repeating it on the past events page.
Is there any way to display both upcoming & past events in the same loop? I will need to do the same thing for the Event Categories too.
It’s possible for sure – but I’m afraid that sort of customization is a bit beyond what we can help you with here on the forum. Some good WP coding knowledge would definitely be required (and you’d probably be interested in filter hooks like parse_query and pre_get_posts here).
Good luck 🙂
September 4, 2014 at 8:36 pm #723592BarryMemberHi! It’s been a while so I’m going to go ahead and close this thread. If we can help with anything else, though, please don’t hesitate to create new threads as needed. Thanks!
-
AuthorPosts
- The topic ‘List Upcoming & Past Events at /events’ is closed to new replies.