Last active
July 26, 2018 01:03
-
-
Save albionselimaj/50b184395b7d3c120da5269d09f456c1 to your computer and use it in GitHub Desktop.
Hide past events from Explore page
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
<?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