Skip to content

Instantly share code, notes, and snippets.

@albionselimaj
Last active July 26, 2018 01:03
Show Gist options
  • Save albionselimaj/50b184395b7d3c120da5269d09f456c1 to your computer and use it in GitHub Desktop.
Save albionselimaj/50b184395b7d3c120da5269d09f456c1 to your computer and use it in GitHub Desktop.
Hide past events from Explore page
<?php
// Hide past events from Explore page.
add_filter( 'get_job_listings_query_args', function( $args ) {
$listing_types = ['event'];
if ( empty( $args['meta_query'] ) || empty( $args['meta_query']['listing_type_query'] ) ) {
return $args;
}
// Only apply to the listing types defined in $listing_types.
if ( ! in_array( $args['meta_query']['listing_type_query']['value'], $listing_types ) ) {
return $args;
}
$args['meta_query'][] = [
'key' => '_job_date',
'value' => date('Y-m-d'),
'compare' => '>=',
'type' => 'DATE',
];
return $args;
}, 100 );
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment