Created
August 23, 2016 17:13
-
-
Save cliffordp/295379c665a27090151ad28fd2bf6a96 to your computer and use it in GitHub Desktop.
Display Past Events in List View if there are no Upcoming Events -- from https://cl.ly/29222x003e22 to https://cl.ly/1z3V0s0Q282Y
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
<?php | |
/** | |
* Display Past Events in List View if there are no Upcoming Events -- from https://cl.ly/29222x003e22 to https://cl.ly/1z3V0s0Q282Y | |
* By Barry 2016-08-23 | |
* From https://gist.github.com/cliffordp/295379c665a27090151ad28fd2bf6a96 | |
*/ | |
function show_past_events_if_no_future_events( $posts, WP_Query $query ) { | |
if ( ! $query->is_main_query() | |
|| ! tribe_is_event_query() | |
|| ! tribe_is_upcoming() | |
|| ! tribe_is_list_view() | |
|| ! empty( $posts ) | |
) { | |
return $posts; | |
} | |
return tribe_get_events( array( | |
'eventDisplay' => 'past', | |
'posts_per_page' => 4 | |
) ); | |
} | |
add_filter( 'posts_results', 'show_past_events_if_no_future_events', 10, 2 ); |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment