-
-
Save pippinsplugins/3018320 to your computer and use it in GitHub Desktop.
Filter events pre_get_posts
This file contains hidden or 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
// Function to display only upcoming events for Sugar Events Calendar on the main Events archive. | |
function sc_filter_events( $query ) { | |
if( is_post_type_archive('sc_event') && (!is_admin()) ) { | |
$meta = array( | |
array( | |
'key' => 'sc_event_date_time', | |
'value' => time(), | |
'compare' => '>=' | |
) | |
); | |
$query->set('meta_query',$meta ); | |
$query->set('meta_key', 'sc_event_date_time'); | |
$query->set('orderby', 'meta_value_num'); | |
$query->set('order', 'ASC'); | |
} | |
} | |
add_action('pre_get_posts', 'sc_filter_events', 9999); |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment