By default, there's not option to sort users by Post count.

In case you are not sure, what I'm referring to is when you click on Users > All Users inside the WP Dashnoard.

I have tried searching all over the place but couldn't find the function for this simple, but yet important thing.

Can anyone throw me a bone, or paste the code if you have on your own Wordpress page?

I would greatly appreciate.

1 Answer 1


Try the following code:

add_filter('manage_users_sortable_columns', 'my_user_sortable_columns');
function my_user_sortable_columns($sortable_columns) {
    $sortable_columns['posts'] = 'post_count';
    return $sortable_columns;

Credit to: Add additional user fields and make them sortable in the user screen

  • hey Scott, thanks for the effort, but this doesn't sort by post count. When you click it sorts by username... Same as you would click on "Username" column.
    – robert0
    Commented Aug 1, 2021 at 11:34
  • 1
    hi Robert - used wrong code in my initial response, code snippet updated - try it again, should work as desired now.
    – ScottM
    Commented Aug 1, 2021 at 19:21
  • Brilliant, worked like a charm, thanks a lot Scott!
    – robert0
    Commented Aug 1, 2021 at 19:26

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge you have read our privacy policy.

Not the answer you're looking for? Browse other questions tagged or ask your own question.