After a lot of trial and error I learnt that WP_User_Query takes an argument fields which can be set to 'all_with_meta'. This reduces number of queries to two for any number of users that are fetched in a single go and also provides benefits of caching. Usage would look like:
$user_query = new WP_User_Query( array('include' => $post_authors, 'fields' => 'all_with_meta') );
Related Posts:
- Getting all user metadata from user
- How to add custom query filters in WP_User_Query
- Searching user meta using WP_User_Query
- Query wp_usermeta alongside wp_users
- WP User Query get all authors with last name starting with specific letter
- How to properly use AND / OR in custom search
- Random users always showing same 8 users
- How to do WP_User_Query for Nested Array value Inside Nested Array field
- How to query 5 users in random who have published more than 10 posts
- WP_User_Query not searching numbers?
- Query Users by post count, last 30 days and display each users post count according to post type
- Get all user with both meta_value
- Group users by meta field, with name of meta field as group title
- Wp_User_Query not sorting by meta key
- WP_User_Query with combined meta query – not working?
- SQL query equivalent to WP User Query
- Filter user list that meta_value is empty
- SQL User Query by Multiple Roles using PHP
- WP User Query fails when searching meta queries and search columns
- WP_User_Query unable to retreive all user at once
- Sort users by “birthday” using WP_User_Query
- Minimize database queries to user tables?
- Query users by capability – uninstall/deactivate callback
- How to display specific posts with WP_Query?
- Hide Administrators From User List except current user (administrator)
- WP_User_Query pulling ACF to loop
- WordPress search posts by author name with autocomplete
- pagination with numbers for WP_User_Query
- How to display user order by role
- Import wp users via one click demo option
- Meta_query on same meta key, with diffrenct values
- Dynamic User Id
- Get users that likes the post
- Passing args to WP_User_Query am I using meta correctly?
- Randomize Users
- Prevent author bio page from showing in search results
- WP User Query with Custom Fields and Search Results
- Get multiple users with meta value in one query and populate WP_User class
- Display if author page is author page of current user
- array of meta values using WP_User_Query
- Get user first name from custom endpoint
- Display the line breaks in user bio without using html
- WP_User_Query and user posts
- construct complex queries with WP User Query
- Storing an array of objects related to each user
- Create one-use post dynamically, add to main query, do not insert post (user profile view)
- query post by author gender
- WP_User_Query orderby meta_val_num
- Query to get last posts from authors of blog
- WP_User_Query not searching
- Replace wp_query with wp_user_query
- Query pages created by deleted users
- Counting instances of words in the results of a post query
- Query posts by post type, author and post meta
- SQL to join u3g_users & u3g_meta_value with repeating data
- Getting user data via ajax
- WP_User_Query Orderby Not Working
- Unusual high query of user meta data
- Set “editor” role to existing user
- How to query users by post count no less than 10
- using custom meta user data to run queries in WordPress
- Merge wp-query and get_users
- Get all wp_users sort by metakey
- Logging search queries for logged-in users
- Best way to query posts and order by relevancy to query
- List users by Year of Birth using a foreach loop to dynamically populate years and data
- Show subscriber id in loop
- Extend WP_User_Query or WP_User to return all custom fields?
- WP_Query within save_post doesn’t include the item that triggered the action?
- Search Functionality broken by the wp 4.2 update
- Sort users by custom user meta value
- How ‘secure’ are loops?
- Get users query makes the site loading time too big?
- Extend user search in the Wp backend area on the users.php page to allow for searching by email domain and role from the “users search” input box
- WordPress WP_User_Query ignores the `meta_query` when called from an Ajax function
- Orderby meta _value that is saved as an array
- Complicated `orderby` based on text in custom field
- Using a Query Loop Block with Variables (Custom Meta)
- Too slow when using both ‘tax_query’ and ‘meta_query’ both in WP_Query
- Use of caller_ get_ posts
- Tax_query terms ID’s using variable
- Order posts by tags count?
- Querying Multiple Custom Taxonomy Terms
- WP_QUERY returns empty set when fired from a WP-CRON scheduled event
- WP_Query, tax_query and term_meta: How to?
- How to pass many ids in post__in?
- How do I run through a WordPress loop called from a filter function?
- slow query – Search for Media Gallery
- is_user_logged_in() throwing undefined function error
- How to order WP_Query to group results?
- Issues with search after added meta_query
- Woocommerce: order posts by meta key
- Modify query posts
- How do I add an item to the WP admin menu?
- Multiple meta query from array
- show related articles in single.php template
- WP_Query to Retrieve Posts from WooCommerce Products that are Only in Catalog
- Search Filter With Custom Taxonomy and Custom Fields : How do I handle it via plugin?
- Add category and user name to recently updated post list
- Main loop querying current template’s info only in custom category archive pages, not my posts