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?
- user_login vs. user_nicename
- How to remove the author pages?
- How to get a buddypress user profile link and a certain user profile field for the current post author?
- Select subscriber as author of post in admin panel?
- Change the Author Slug from Username to Nickname
- Adding fields to the “Add New User” screen in the dashboard
- Echo author ID in author.php
- Difference between update_user_meta and update_user_option
- How to filter users on admin users page by custom meta field?
- Woocommerce: assign an “author” to a product
- How can HTML be allowed in Author Bio?
- get_user_meta() doesn’t include user email?
- Programatically change post author
- Automatically delete inactive users after 2 months
- Use author author display name in permalink structure for pages and posts
- Check if user is admin by user ID
- How to display a public profile page for registered users with custom slug?
- Change the author slug from nickname to ID
- How to let contributors to create a new revision(draft) editing their published posts
- Return all users with a specific meta key
- Restrict one post per author
- How to get author’s name by author’s id
- Where the Nickname is being used in WordPress
- Author page: Comments and Ratings?
- How to display custom user meta from registration in backend?
- Allowing an email as the username?
- Grouping users under parent user
- get_users is expecting unserialized meta_value
- WordPress: How to get the current logged in author page URL?
- Display edit link if post author is current user
- Give Author users the right to embed
- Force display name as full name
- How to get post author name by its ID inside a function?
- How to get users by a custom field / by user meta data?
- How can I publish a post with two or more authors?
- How to create a template for a custom URI associated with the user
- How to order users alphabetically by their last name?
- Getting all user metadata from user
- How do you add a custom option to user data?
- Extending WP_User class and using this sub-class during the whole lifecycle
- Wp_User_Query not sorting by meta key
- Add a button to users.php
- How we can get the user id by its display_name
- Displaying custom post types in author.php
- WP_User_Query with combined meta query – not working?
- How to use hyperdb to separate and share a user dataset between wordpress installs?
- LEFT JOIN, INNER OUTER JOIN, LEFT OUTER JOIN is driving me crazy. Please help?
- \WP_User Object | What’s the Difference Between {caps} and {allcaps}?
- Add rewrite endpoint to author page + pagination
- Show Biographical Info while creating new user
- What’s a good way to put authors into groups
- Permalink to user profile
- include user profiles in search results?
- Show Author in custom rss feed
- 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?
- Where to Store Custom User Fields
- What is the difference between user_description and description?
- How can an author be subscribed to the posts of another author and receive notifications of the new posts?
- No authors in change author dropdown
- Show author archive pages for authors with no posts
- Plugin that would allow WordPress Authors to “follow” other Authors and query “Activity Info” from that
- Querying Email Addresses for a List of Users with Same Last Name?
- Display sortable User meta column in admin panel user’s page
- Show User Their Password
- User profile custom field
- More posts from the current author
- Authors Page : A page of authors
- Showing user ID on user main page from screen options
- List authors of site with link and gravatar
- Front end user meta options for users
- Authors details such as social media links, emails etc → Is this Meta or something else?
- How we can get the author ID by its Name
- How to hide posts count and posts of other users from edit.php for contributors and authors
- User Published Post Count
- Custom size for image uploaded to custom field in user profile?
- What capability allows someone to change a page’s/post’s author?
- ACF Upload Image in front-end with custom form
- How to get posts without author?
- Creating distinct pages for author profiles and lists of posts by author