Opened 7 years ago
Last modified 14 months ago
#49418 new enhancement
Ability to order users by number of posts in custom post type
| Reported by: | meevly | Owned by: | |
|---|---|---|---|
| Priority: | normal | Milestone: | Awaiting Review |
| Component: | Users | Version: | 5.4 |
| Severity: | trivial | Keywords: | close 2nd-opinion |
| Cc: | Focuses: |
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
@
14 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.
![(please configure the [header_logo] section in trac.ini)](/chrome/site/your_project_logo.png)
@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/