I assume the above function works well for you to get the count for the posts including the custom post types
and you just need help in ordering the users using this count.
I assume you already have the list of user ids lets say the array $userids
Lets use asort and arsort to do so
Put the above code in the active theme’s functions.php
file and use the below in the file where you need to get the ordering
$arr = array();
foreach( $userids as $userid ) {
$arr[$userid] = foo_count_posts($userid);
}
Now $arr
is the array with userid as key and post count as the value
To get the ascending order use
asort($arr);
var_dump($arr);
To get the descending order use
arsort($arr);
var_dump($arr);
Related Posts:
- Custom post type for ‘staff’ versus using wordpress user profiles?
- Showing User’s Post Counts by Custom Post Type in the Admin’s User List?
- Prevent trash/delete action on specific post types
- Custom post type support for get_users(‘orderby=post_count’);
- Front end registration/login & publish/update 1 custom post
- User roles – enable custom posts disable posts
- Allow User to Edit Page Based on their Email
- How to restrict specific post types from being read or added by specific user roles (eg. author)?
- How can I get the last posts by user role?
- Assigning a role to a specific custom post type (and ignoring other post types)
- WordPress allow access only one custom post type “xyz” to custom user role but need to hide all admin panels
- How to show custom post type count in the users admin page
- Community and User Generated Content Website: Have been thinking about Drupal but leaning on WordPress heavily
- Delete Current Author Frontend user while delete custom post type
- WP-Admin edit.php & post.php slowdown after import of 10k users
- Link users to a custom post type
- Ajax Check Post Status
- Want to Add Custom Fields for Uploading video to WordPress Users from front end
- how to delete all users and posts based on ‘user_meta’?
- Roles for Custom Post Types
- Is using taxonomies the way to go here or would custom post types be better?
- Hiding posts by other users and non-logged in
- Users create/join groups
- Disable user from updating certain posts
- Query posts based on the meta key values of logged-in users?
- How to restrict author to only access one custom post type ?
- Create custom post with custom user rules
- Associate multiple users to custom post type
- How to assign permissions for a CPT to a user
- How can i display movies in profile page, added by an user?
- Custom User role not working with custom post type
- get comments by current user inside page template
- how to associate several authors to a custom post type
- Assign post type to many users
- Check if user has comment on current post
- Query within a foreach within a query (queryception)
- Showing User’s Post Counts by Custom Post Type in the Author.php?
- Add a custom post when inserting a new user in WordPress?
- Preventing role reading others posts
- Plugin needed to allow subscribers to post articles on the front end without admin approval [closed]
- Display custom post front end filter by ACF equals current user
- users post count
- Clone wp-admin/users.php (Users Admin Page)
- Link custom post type to users membership
- Show all post type posts in manage users posts column
- Limit 1 post by user in each custom post type
- Get all of a user’s posts (custom post type) then get cumulative value of a specific meta_key value from those posts
- Assign a Post to a User
- Add WordPress users to a custom post type
- Custom Post Type Query by user id
- Autofill advanced custom field with user data
- connect users to Custom post types
- Reference field of users in custom post type
- Custom Post Hierarchy and users
- UPDATED: Save a custom_field value when automatically creating a post using wp_insert_post
- Creating multiple profiles under one user to assign to particular posts
- Allow viewing the edit screen for a post type, but not make/save/publish/update changes
- Control what custom posts a user can see
- Associate custom categories to different user IDs
- Display and Allow users to edit their own profiles
- Check in function on custom page
- WordPress and Unity high scores table
- how to show Author post type count
- How to hide CPT files from media library programmatically
- Determine which template-{slug}.php is being loaded
- How to remove/hide elements from the admin menu?
- Show Custom Post Type by Author
- Exclude current post when getting related post on custom post type and taxonomy
- custom post type default permalink
- Allow Administrator role access to custom capabilities [duplicate]
- custom comments on specific post type
- Adding dropdown select meta box to custom post type – seems restAPI is interfering
- Crafting WP_Query array, sort by date
- WordPress wrapped added a span tag to every single p tag
- Custom Widget WP_Query problem
- Custom Fields for Custom Post [closed]
- Show Custom Post Type meta boxes only on Page Edit
- How can meta boxes be added to “unknown” custom posts?
- link to a random custom post while excluding current post
- Create Array from custom post type to display a slider
- Fix permission error for deleting custom post from front-end?
- Custom post type slug 404
- Counts Posts ( custom post type ) by Author in author.php
- WordPress multisite – is it possible to have different taxonomies for each site?
- How to use a specific custom field in a custom post type as slug
- Wp custom post custom capability not working together
- Display Taxonomy Term Children in a Drop Down without Submit Button
- Problem retrieving informations and displaying desired structure with custom post type and taxonomy
- wp_query can’t get max_num_pages in custom post type
- WordPress CPT Taxonomy Dashboard Search – How to include taxonomy in search?
- Saving custom JSON as custom post type
- Preview url not working outside wp-admin
- Post Tags not working for Custom Post type
- How can I group by Taxonomy on Custom Post Type while filtering out based on custom Meta
- Custom Post Type vs Shortcode: Which one is more performant?
- Show list of categories in post editor only from current custom post type
- Permalink of Custom Post Type
- How can i manually relate pages?
- has_archive for default post type
- Custom Post Type Archive Title Lowercase