Skip to content

Instantly share code, notes, and snippets.

@andrasguseo
Created May 24, 2024 20:48
Show Gist options
  • Save andrasguseo/1296f7300340b8d9f37026d0dcb453b2 to your computer and use it in GitHub Desktop.
Save andrasguseo/1296f7300340b8d9f37026d0dcb453b2 to your computer and use it in GitHub Desktop.
Filter Bar > Sort filter options
<?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