Created
May 24, 2024 20:48
-
-
Save andrasguseo/1296f7300340b8d9f37026d0dcb453b2 to your computer and use it in GitHub Desktop.
Filter Bar > Sort filter options
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
<?php | |
function tec_custom_filter_values_order( $values, $field ) { | |
// Bail if it's not the right field | |
if ( $field !== '_ecp_custom_2' ) { | |
return $values; | |
} | |
$order = ["New", "Beginner", "Experienced"]; | |
usort( $values, function( $a, $b ) use ( $order ) { | |
return array_search( $a['name'], $order ) - array_search( $b['name'], $order ); | |
} ); | |
return $values; | |
} | |
add_filter( 'tribe_events_filters_additional_field_values', 'tec_custom_filter_values_order', 10, 2 ); |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment