Created
July 16, 2025 00:05
-
-
Save rniswonger/4af73f3359dd68898e7b3b74d6db9299 to your computer and use it in GitHub Desktop.
WordPress: Sort ACF Location Rule values alphabetically to make them easier to find when defining a Field Group
This file contains hidden or 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 | |
/** | |
* Sort ACF location rules values alphabetically | |
*/ | |
add_filter( | |
'acf/location/rule_values', | |
function ( $values, $rule ) { | |
if ( is_array( $values ) ) { | |
asort( $values, SORT_STRING | SORT_FLAG_CASE ); | |
} | |
return $values; | |
}, | |
10, | |
2 | |
); |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment