Are you using WordPress 3.1+? There’s a nice get_users()
function that’ll do the trick! However, you will need a little magic to boot:
add_action( 'pre_user_query', 'wpse_11832_pre_user_query' );
/**
* Adds "post_count" to the SELECT clause. Without this, the "post_count"
* property for users will be undefined.
*
* @param object $wp_user_query
*/
function wpse_11832_pre_user_query( $wp_user_query ) {
if ( $wp_user_query->query_vars['orderby'] == 'post_count' )
$wp_user_query->query_fields .= ', post_count';
}
And example usage:
<?php foreach ( get_users( 'order=DESC&orderby=post_count&number=5' ) as $user ) : ?>
<?php echo $user->display_name; ?> (<?php echo $user->post_count; ?> Posts)
<?php endforeach; ?>
Important: You must order by post_count
, otherwise it will be undefined.
Related Posts:
- How to *remove* a parent theme page template from a child theme?
- How to Change 404 page title
- How to update the delete user confirmation form?
- How to redirect WordPress home page to custom static HTML page
- How can I create an alternative home page?
- Modify custom Users Manage page
- How to Save Different Usermeta Fields According to User Role?
- page_template toggle between 2 templates + 2 permalinks for same post
- Set user loggin status?
- How do I deque the default stylesheet?
- How can I add data to a custom column in the Users section of the wordpress backend?
- Unique User Account Number + Displayed Via Shortcode
- Woocommerce Product page edit
- Last time a user logged in
- For custom templates, is it better to use `template_include` or `type_template`?
- Updating Custom WordPress User Meta Field via REST API
- How to pass external variables to the wp_new_user_notification_email filter?
- How can I allow access to multiple users, using the same login, at the same time?
- Creating user relationships
- Function to allow “Anyone can register”?
- Make custom user table column filterable
- Add ‘Creator’ User Meta when adding user
- Follow me for WordPress blogs (multi-authors)
- Javascript Solution Remove Specific Tag but leave the rest in a specific DIV
- Change the Labels of Users to Customers in Admin
- need help with a user-specific custom page template
- Prepopulating a specific page template with HTML/CSS
- custom meta box for page default template
- User can not login
- Allow guests to use WP Customizer but disable save button
- Users can only view their content from the front end
- Multi-site User Sessions
- How To Load an HTML File As A WordPress Page (With No 301/No Redirect)
- Problem with custom user meta field
- Customizing Users in Admin Area
- how to make a custom field readonly or disabled by user role?
- How to make wordpress use a non-wordpress users table?
- How to create custom search page
- WordPress archive index page
- How to create a custom WordPress front page
- Custom Same Page Search
- change top banner content on specific page
- How to set up conditionals in page templates?
- How To make Custom page of every Category
- Remove Sidebars from page
- Personalized Gallery what are my options?
- how or where wordress collect unlogged user session
- No plugin populate user information in to form
- Product page not found if product data is set Appointment Service
- Invitation link to a site in multisite network does not work?
- Page with some post value id showing page not found
- WP_User_Query Search Multiple Keywords from a Multi-Select Field?
- Why does a custom php code inside a custom template not get executed?
- How to use the same custom page template to iframe multiple urls with entry of new url entered from backend
- Create page when a new site in multisite network is created?
- Custom stylesheet not loading
- Displaying Child Page’s Information
- How to display all post from the same current usermeta
- Highlight specific user with custom field value
- Change the functionality of wordpress users module in admin
- Changing starting number of User ID
- Adding pages to the Admin panel
- Setting Custom WordPress “Posts page” AS “Front page”
- Custom search by several options send on form not works
- Page template with custom html fields inside a content
- User registration add user ID?
- How to create functions that affect only a specific user
- Single page template
- Adding page Title in a custom coded page
- Create users via PHP
- Use wp_login_form function to login with a custom user table?
- use another theme for just one page
- Is it possible assign a secondary existing role to already existing one?
- User Query Multiple Orderby Clause
- Some data of one custom user profile is erased when I update another custom user profile
- How to: Easily Move a WordPress Install from Development to Production?
- Is there a flowchart for WordPress loading sequence?
- How to change the default registration email ? (plugin and/or non-plugin)
- Essential technical features for high-end WordPress web hosting? [closed]
- How to remove admin menu pages inserted by plugins?
- How to put logs in WordPress
- How to get the Date Format and Time Format settings for use in my template?
- How To Add Custom Form Fields To The User Profile Page?
- Where are Additional CSS files stored
- Best Practices for Regression Testing WordPress Websites?
- Remove wrapping div and ul from output of wp_nav_menu
- What Is The Use Of map_meta_cap Filter?
- get post author id outside loop
- Custom Walker: how to get ID in function start_lvl
- Creative uses of WordPress [closed]
- How do I make my child theme re-apply the settings that were customised when its parent was active?
- Multiple Inputs in a Customizer Control
- New WP_Customize API – how does it work under the hood?
- Embedding a SOAP Client into a WordPress Plugin?
- Is there anything that Joomla or Drupal can do that can’t be done in WordPress? [closed]
- Update widget form after drag-and-drop (WP save bug)
- Data sanitization: Best Practices with code examples
- How to benchmark a WordPress installation? [closed]
- Should I delete the default themes?
- Moving WP install from local to live, what about wp_posts GUID?