Skip Navigation

[Resolved] Need to order View query results by Post author display_name not Post author ID

This is the technical support forum for Toolset - a suite of plugins for developing WordPress sites without writing PHP.

Everyone can read this forum, but only Toolset clients can post in it. Toolset support works 6 days per week, 19 hours per day.

Sun Mon Tue Wed Thu Fri Sat
- 10:00 – 13:00 10:00 – 13:00 10:00 – 13:00 10:00 – 13:00 10:00 – 13:00 -
- 14:00 – 18:00 14:00 – 18:00 14:00 – 18:00 14:00 – 18:00 14:00 – 18:00 -

Supporter timezone: Asia/Kolkata (GMT+05:30)

This topic contains 1 reply, has 2 voices.

Last updated by Minesh 1 year, 8 months ago.

Assisted by: Minesh.

Author
Posts
#2597485
Screenshot 2023-04-20 at 2.24.43 PM.png

Tell us what you are trying to do?

I have several views set up to display search results of intermediary posts - they should be ordered by the post author, alphabetically. However, it's ordering by the post author ID instead of the display_name. How can I change this?

Is there any documentation that you are following?

I don't see anything exactly like this.

What is the link to your site?

hidden link

Search by any "System" and you'll see alphabetized results on the right. The results show which companies offer services in these different systems. The companies add/edit their own info and they each have a user with their company name as the Display Name - so each company user is the author. Almost all of the company users were set up at the same time, in alphabetical order, so the user ID is in order. However, the last three to be added are not in alpha order and show up at the bottom (Cenevia, Georgia Association..., New York Statewide...).

Is there a function that I could add to the child theme to pull the author display name rather than the author ID for the sorting?

Thank you for your help!
Michelle

#2597603

Minesh
Supporter

Languages: English (English )

Timezone: Asia/Kolkata (GMT+05:30)

Hello. Thank you for contacting the Toolset support.

As you can see the WP_Query class orderby options. You can set the posts to order by author (ID) but there is no way to order posts by author name. As to query author name it will require to query user query and we can not merge post query and user query.
=> https://developer.wordpress.org/reference/classes/wp_query/#order-orderby-parameters

It will require custom code that is beyond the scope of our support policy. If you need custom programming for your project, please feel free to contact any of our certified partners:
- https://toolset.com/contractors/