apply_filters('wpstagerintegration_calendar_filter_taxonomy_terms', array[] $terms, string $taxonomy): array[]: array[]
apply_filters('wpstagerintegration_calendar_filter_taxonomy_terms', array[] $terms, string $taxonomy): array[]: array[]Description
Filters the terms displayed in the calendar filter
Example:
// Only include 'Amsterdam' and 'Rotterdam' as values to filter on
add_filter( 'wpstagerintegration_calendar_filter_taxonomy_terms', function ( $terms, $taxonomy ) {
// Return original values if we're not filtering values for the 'location.city' field
if ( $taxonomy !== 'location.city' ) {
return $terms;
}
// Init
$subset = array();
// Loop over terms
foreach ( $terms as $term ) {
// Skip terms not matching specific values
if ( ! in_array( $term[ 'value' ], array( 'Amsterdam', 'Rotterdam' ) ) ) {
continue;
}
// Add $term to $subset
$subset[] = $term;
}
// Return only a subset of terms
return $subset;
}, 10, 2 );Parameters:
| Parameter | Type | Description |
|---|---|---|
$terms | array[] | { |
$taxonomy | string | The taxonomy to filter the terms for |
Returns:
array[] Must return an array of terms (arrays with the above sub keys)
Information
| File | class-calendar.php line 2428 |
|---|
Full Code
/**
* Filters the terms displayed in the calendar filter
*
* @param array[] $terms {
* An array of terms
*
* @type string $taxonomy The taxonomy of the term
* @type string $label The label of the term
* @type string $value The filter value
* }
* @param string $taxonomy The taxonomy to filter the terms for
*
* @return array[] Must return an array of terms (arrays with the above sub keys)
*
* @example
* // Only include 'Amsterdam' and 'Rotterdam' as values to filter on
* add_filter( 'wpstagerintegration_calendar_filter_taxonomy_terms', function ( $terms, $taxonomy ) {
*
* // Return original values if we're not filtering values for the 'location.city' field
* if ( $taxonomy !== 'location.city' ) {
* return $terms;
* }
*
* // Init
* $subset = array();
*
* // Loop over terms
* foreach ( $terms as $term ) {
*
* // Skip terms not matching specific values
* if ( ! in_array( $term[ 'value' ], array( 'Amsterdam', 'Rotterdam' ) ) ) {
* continue;
* }
*
* // Add $term to $subset
* $subset[] = $term;
* }
*
* // Return only a subset of terms
* return $subset;
* }, 10, 2 );
*/
$terms = (array) (apply_filters( 'wpstagerintegration_calendar_filter_taxonomy_terms', $terms, $taxonomy )💡 If you ever get stuck or have a question, please check our FAQs, our Free Integration Service, our paid Full Integration Service, or reach out to us!

Get WP Stager Integration
🎁 Limited offer: Use code WELCOME26 to get your first month for free!

