Hallo @ all,
my field has a filter for 2 taxononies.
While edit the post i want to sort both taxonomies alphabetically.
For Example:
Einzelgruppe = “Alex, Mick, Roy”
Untergruppe = “Bert, Fred, Sam”
For the select field (2. Pic) i want the order:
Alex
Bert
Fred
Mick
Roy
Sam
What is the right way to manipulate the sorting order?
Thanks for your support!
Frank
If I understand you correctly, it looks like you are trying to get the choices in the post object to display in alphabetical order.
Have you tried the following:
function my_post_object_query( $args, $field, $post_id ) {
// modify args
$args['orderby'] = 'title'; //title of the post
$args['order'] = 'ASC'; //order a-z; use DESC for z-a
// return
return $args;
}
add_filter('acf/fields/post_object/query/key={field key}', 'my_post_object_query', 10, 3);
Change the field key to the field key for your post object (it should look like this: acf/fields/post_object/query/key=field_508a263b40457 . Then add the code to your functions.php file
Documentation Hier