I am attempting to orderby the author_name when you click on the Author arrow on a list of tickets. When you click the arrow, the names are ordering by something I cannot identify. I want them to order by the actual name and not the ID number for the user.

How do I get the orderby to query by the “nice name” of the user(author)?

public function add_support_ticket_author_query( $query )
    if ( $query->is_main_query() && ( $orderby = $query->get( 'orderby' ) ) ) {
        switch( $orderby ) {
            case 'author':
                $query->set( 'meta_key', 'author_name' );
                $query->set( 'orderby', 'author_name' );

Read more here: Query Set Order By Author


If you know the solution of this issue, please leave us a reply in Comment section, to update the question.

Wordpress related questions and answers: