Skip to content

Instantly share code, notes, and snippets.

@joshfeck
Last active July 21, 2019 21:44
Show Gist options
  • Star 2 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save joshfeck/d68b3c6da61c92ce92c4f77a958a20de to your computer and use it in GitHub Desktop.
Save joshfeck/d68b3c6da61c92ce92c4f77a958a20de to your computer and use it in GitHub Desktop.
<?php
//* Please do NOT include the opening php tag, except of course if you're starting with a blank file
function custom_posts_where_sql_for_only_expired() {
return ' AND ' . EEM_Datetime::instance()->table() . '.DTT_EVT_end < "' . current_time( 'mysql', TRUE ) . '"
AND post_status = "publish"';
}
add_action( 'loop_start', 'my_custom_event_view_only_expired' );
function my_custom_event_view_only_expired() {
if ( is_page( 'past-events-page' ) ) { // swap in the page slug here for to match the page where you display the list
add_filter( 'posts_where', 'custom_posts_where_sql_for_only_expired' );
}
}
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment