Created
August 12, 2019 18:43
-
-
Save csalzano/476191cc0403ff93f37bac95dc702bf5 to your computer and use it in GitHub Desktop.
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
$taxonomy_name = 'venue'; | |
//Only include venues from the current year in REST API responses | |
add_filter( "rest_" . $taxonomy_name . "_collection_params", 'hide_old_venues', 10, 2 ); | |
function hide_old_venues( $prepared_args, $request ) { | |
//Populate the default value of the include argument to only include terms with specific IDs in the meta box | |
$prepared_args['include']['default'] = get_terms( array( | |
'taxonomy' => $taxonomy_name, | |
'fields' => 'ids', | |
'hide_empty' => false, | |
'meta_query' => array( | |
array( | |
'key' => 'venue_event_year', | |
'value' => date( 'Y' ), | |
), | |
), | |
) ); | |
return $prepared_args; | |
} |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment