Skip to content

Instantly share code, notes, and snippets.

@csalzano
Created August 12, 2019 18:43
Show Gist options
  • Star 0 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save csalzano/476191cc0403ff93f37bac95dc702bf5 to your computer and use it in GitHub Desktop.
Save csalzano/476191cc0403ff93f37bac95dc702bf5 to your computer and use it in GitHub Desktop.
$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