Opened 6 years ago
Last modified 6 months ago
#49418 new enhancement
Ability to order users by number of posts in custom post type
| Reported by: |
|
Owned by: | |
|---|---|---|---|
| Milestone: | Awaiting Review | Priority: | normal |
| Severity: | trivial | Version: | 5.4 |
| Component: | Users | Keywords: | close 2nd-opinion |
| Focuses: | Cc: |
Description
When searching for users by post_count, post type post is hardcoded in WP_User_Query class at line 765. I would like to suggest adding a parameter that allows sorting users by post count in a custom post type.
Attachments (1)
Change History (3)
#2
@
6 months ago
- Keywords close 2nd-opinion added
I am less sure about leaving this to plugins than I was five years ago, but the ticket does not have any activity since then.
For an update on the hardcoded post location, it is now on line 1008 in WP_User_Query::parse_orderby().
Note: See
TracTickets for help on using
tickets.
@meevly Thanks for the ticket and welcome to Trac!
This functionality would be more appropriate in a plugin instead of core, especially if one person wants a count for a specific custom post type and another wants to sort on the total of multiple post types. (See also related ticket:15200#comment:1 about showing the counts.)
Admin Columns Pro might work for you. The free version enables you add a Post Count column for a custom post type, and sorting that column is a Pro feature.
https://wordpress.org/plugins/codepress-admin-columns/
I found out about that plugin when searching the support forum:
https://wordpress.org/support/topic/sort-user-php-by-last-name/
And there is at least one support topic about creating your own solution:
https://wordpress.org/support/topic/creating-custom-columns-of-users-and-sorting-them/