You are arranging the users within foreach block. Why don’t you arrange them first and then go with the loop for displaying info. If you do that, you will need only one query.
Do this in this order-
1. Do the query with get_users
. You can add an extra parameter who=author
. This will force to search only the authors. I believe the response will be better. This will return an array of WP_user
Object.
2. Use a foreach
loop to clean lastname
3. Sort the array of object based on their lastname
. You can use usort() for this
4. At last, use another foreach
for displaying everything.
Related Posts:
- How to check if a user (not current user) is logged in?
- If Else Gravatar Author Picture
- Order the users by the date of their latest post
- Author list ‘special’ author first then ‘normal’ author
- get_the_author_meta( $field, 0 ) returns the administrator $field
- Author custom fields post meta, the code?
- How can I get the author description’s excerpt?
- Filter Author Bio
- How to use Buddypress xProfile field as WordPress Bio
- Multiple Unique Author Profiles
- Get avatar of the logged-in user in WordPress
- Display author name, outside the loop, if they haven’t published a custom post
- Difference between last_name and user_lastname
- get_the_author_meta not working
- Creating a button from data from Author meta
- How do I change the user via SQL?
- WordPress Author Information show paragraph?
- the_author_meta not resetting
- Removing “HTTP://” From the_author_meta?
- Select subscriber as author of post in admin panel?
- How to display custom user meta from registration in backend?
- Allowing an email as the username?
- Display edit link if post author is current user
- How to get post author name by its ID inside a function?
- How we can get the user id by its display_name
- WP_User_Query with combined meta query – not working?
- How to add follow functionality to multi-author wordpress site?
- Search multiple meta keys at once
- How may I filter get_users() similarly to pre_get_posts?
- How can an author be subscribed to the posts of another author and receive notifications of the new posts?
- ACF Upload Image in front-end with custom form
- Making WordPress author follow button, need missing ingredient
- delete_user_meta Delete one value out of array
- Get the comment author ID by the comment ID
- Upload files programmatically to users
- How to add country drop down menu to the user profile?
- Limit number of posts a user can make per minute?
- Replace Gravatar with img URL for avatars
- Custom Author Fields + Existing Taxonomy – Integrating the Two Dynamically?
- WordPress Author Page
- Users roles, make a page belonging to multiple users
- What is wrong with this code?
- Limit REST API output to current logged in user that is also author of the content
- Display only entire most recent post on author page?
- How to get the user description with get_users?
- get current user not working
- stop login if user_status equal zero
- How can i create an array user meta?
- Distinguish profile user and admin user IDs / get ID of user being edited
- Custom Author Loop
- Showing author’s page with no posts
- Get all user meta by meta key instead of ID
- Plugin for an author bio popup box?
- Force a user’s posts category
- Conditional/Check: IF comment author is the post author
- Get last revision author, author-link and date
- Authors List page – How to include only those with wp_user_level as Author
- Delete User via Frontend
- Create Next and Previous Link to User orderby Last Name
- How to list users by custom field?
- Author posts url… way to get display name to be url instead of user’s ID?
- User description only displayed for logged user
- Gather posts into a cart/lightbox and share with another user
- Assign random (and unique) user meta upon registration
- how to set default update_user_meta values wordpress
- Order users by user role
- Get user by meta key – WP multi site
- Cannot Update user meta in custom field
- Get 404 when try open author page
- Get Author Count By Day, Week and Month
- Recovering the table wp_usermeta from users
- Detect and make links nofollow in author description
- Show number of posts by logged in user
- WordPress /users/me endpoint request forbidden
- New User Save Filter
- Assigning multiple or additional capabilities to specific users or how to create additional roles like bbpress roles?
- Get users with different roles and call function on each of them (user_meta)
- Display all authors in a theme template
- Featured image for social sharing ot author archive page
- How to show list authors with at least five posts published
- How to have certain WordPress settings set by default on a per author basis
- Filter Author Link for Numerous Authors for each to go to unique page
- Delete user meta but only if found in array
- Can I add a unique code for each user based on the location?
- can’t see information on author page that don’t have posts
- how add more field to wp user and save it to database
- How to create many author’s page?
- wp_get_current_user Not working
- get_author_posts_url() Not working
- How to get the id of recently registered user from database?
- user and usermeta table not found
- Username has been exposed
- How to get the Author type Label Language
- Sticky post of current viewing author?
- How to get latest page (not post) of User and display the content
- show count author post today
- if else for custom $curauth-> field
- Author.php display profile for all types of users
- Get all user with both meta_value
- why is there an author.php