I can see in your code you did mistakes with meta key arguments. You must use underscore instead of hyphen sign.
Here is corrected code:
$args = array(
'number' => 5 ,
'meta_key' => 'post_count',
'meta_value' => 10,
'meta_compare' => '>',
'orderby' => 'rand'
);
$user_query = new WP_User_Query( $args );
if ( ! empty( $user_query->get_results() ) ) {
foreach ( $user_query->get_results() as $user ) {
echo $user->display_name ;
}
} else {
echo 'No users found.';
}
Hope this will work!
Related Posts:
- How to display user order by role
- Get multiple users with meta value in one query and populate WP_User class
- Query pages created by deleted users
- How to query 5 users in random who have published more than 10 posts
- Return only Count from a wp_query request?
- Make a WP Query search match exactly the search term
- WP_Query: query posts by ids from array?
- Query WooCommerce orders where meta data does not exist
- pre_get_posts with get_posts
- author.php with ACF and CPTs
- Query Custom Meta Value with Increment
- Identify which loop you are hooking into; primary or secondary?
- How to query for a week using key => value WP_Query argument notation?
- Finding all results from database within 500 miles of the given latitude and longitude [closed]
- Show only oldest post by author
- How to get the posts published in last two days using WP_Query?
- Finding the next 5 posts
- Dynamically Override Fancy Title – Part II
- Transient pagination not working properly
- Can not switch the queried post in pre_get_posts hook
- view queries made?
- How to detect custom query inside `posts_where` hook?
- Pass the same object to multiple widgets in a template with one query
- Is temporarily overwriting $wp_query a bad idea?
- Get the post permalink within the loop but without additional DB query
- List the 5 most recent child pages
- How to output different posts per page?
- What is considered a default query for the request filter?
- $wpdb insert is not work
- How to find exact match for search term in WP_Query? What is the additional string added in LIKE query in WP_Query?
- Query total number of posts
- Creating a custom search for a specific post type
- How to query a custom post type with a taxonomy filter but display post type archive page?
- Custom query for sidebar isn’t returning results
- Change query_posts to WP_Query in page but does not work
- Optional Meta Query
- Set conditional on template based on referring page slug
- Iterating through $wpdb query without using get_results for large query results
- Filter posts in category archive page by year using a dropdown
- Set global $wp_query/$post variable for dynamic page generation
- Query posts intersecting tags and categories
- Include data from custom table in WP_Query
- How to get a query variable?
- date_query seems to be ignored by wp_query
- Query Page Content From Theme Options?
- Better wordpress attachment query than this
- Modify Search Query if original Query gave no results
- Include current post into loop
- Is it possible to query from external database? [duplicate]
- Can’t sort custom post type by random
- Query posts that contain video?
- Filter post query to only show direct children of category
- Reduce number of SQL queries inside WP_Query loop to fetch author data
- How to set up hierarchical relationships without using plugins / meta query
- Storing an array of objects related to each user
- wordpress udpate query not equal to
- Is it possible to retrieve posts depending on meta_key LIKE condition? [duplicate]
- WP_User_Query orderby meta_val_num
- WP_Query custom order and pagination
- Unable to paginate a custom page query
- meta_query where the meta value is not the post title
- Multi-layered WP_Query
- `offset` WP_Query argument dont work via `pre_get_posts`
- Pagination of custom page with custom fields query
- Woocommerce Get Orders By Meta Value
- Exclude post from wp_query based on custom field boolean
- Get posts that match defined arrays of tags
- Move some posts to end of sort order, even if there is a sort in the wp_Query already
- Order posts by tags count?
- Strange results from WP_Query
- Is there a way to control both Order By and Order query parameters from one input field
- I need query_posts() to order results first by a meta value and then by post ID
- Is my code correct?
- Slow wp_posts and wp_postmeta query using Advance Custom Fields
- Meta query doesn’t remove placeholder escape before query
- Get all wp_users sort by metakey
- How to show post title in content editor in backend?
- List users by Year of Birth using a foreach loop to dynamically populate years and data
- What is the best way to reset a search on a meta_key / meta_value?
- How can I modify standard search query to include also ACF custom fields values?
- Show subscriber id in loop
- Bring a post to the top of the query if it’s in a certain category?
- WP_Query with child element
- Using URL variables on a custom WP_Query
- How to get query results for the next page
- Using WP_Query to re-query and sort results using a date?
- Pagination is not working on custom query inside a custom home page template
- Loop through multiple custom fields with increasing number
- How to organize a WP_Query’s list of posts by category and display category title?
- Need help setting up a search form for wordpress [duplicate]
- WordPress Query showing multiple titles
- custom query to get posts
- confirm my booking with phone number
- Get WP_Query query after execution?
- shortcode using multiple WP_Query’s with multiple category names not fully functional
- WordPress query very slow on +/- 300k DB entries and 7 INNER JOIN
- A Depth Like Parameter For “get_posts”
- Search query alteration not working for meta values
- Advanced Search – Is this possible?
- Use value from meta key array for use in WP_Query