Manual Sort Order for Authors or Users – WordPress

Sorting Cat. Get it? Like "Sorting Hat?" Any Harry Potter Fans out there?

Sometimes it’s necessary to manually select the order in which to sort your authors on your page listing all your authors or users. It is a little tricky to do, but I’ll break it down for you in this simple tutorial.

First, you are going to need to add a custom meta field for your users. There are many ways to do this that are not discussed here, though using Advanced Custom Fields is my favorite method, as the UI is all visual and requires no coding.

In this example, I created a custom meta field for authors named “order”. This is the field in which we are going to manually enter the order in which we want our authors to appear. In the user edit screen in the WordPress backend, setting our “order” value to ‘1’ should result in that author being listed first, with each subsequent number being listed after. I haven’t tested it to see if negative numbers would work, but I imagine they might!

Now to actually list the authors on our author results template. You need to have a separate template file for this. Typically to actually use it, you just create a page template and then select this template from the dropdown menu in the page edit screen.

The following code will query all the authors satisfying our parameters, and then sort them in our required order. I have a custom meta key which I use to specify which authors get listed, and it is simply a checkbox for the meta key named “display_author”. A meta value of “1” indicates that the box is checked and that other should be displayed. You could create this yourself, just like you created the “order” meta key if you wished. In my case, I have no other parameters, but you may want to add some, perhaps to specify that you only want “authors” as opposed to “subscribers” or any other role.

Now for the code. In this example, we are going to display the names of the authors with links to their profiles, a thumbnail, and a brief bio excerpt.

There you have it! This should be a good starting point to use for your own author page. Take a look at the comments to learn exactly how you can customize this.

One simple customization would to reverse the order of the authors which is actually quite simple. All you need to do is replace


Simple! Let me know if you have any questions about this in the comments. Credit goes to ClarkLab for the idea and much of the original code, including the cmp function that actually does the sorting. As of 2017 the original post seems to be missing, but I’ll leave the link to his site up.

About Brian Johnson

Brian Johnson is a website developer and designer living in Minneapolis, Minnesota with a passion for code and WordPress. He spends his days building WordPress websites for small businesses, developing new code with the online community, and living life.

8 Comments on “Manual Sort Order for Authors or Users – WordPress”

  1. I’m trying to make run this in a page but i have problems to see the users… Im trying to show all the authors and give a specific order to each one by the administrator via wordpress panel. With Advanced Custom Fields i made a function for all the authors, specifically i made an ‘number Field Type’ … but when i assign this values in your code on functions.php .. only shows me the massage ‘No authors found’ .. Can you help me.

  2. This had me stumped until I came across your solution – which is actually quite simple. Love the way you’ve explained it and commented the code.

    (There’s one tiny typo – 5th paragraph, 8th word, should be “authors” instead of “others”)

    Thanks for taking the time to write this up and publish it. And leave it out there. I realize you did this years ago, but it’s still valuable today.

    1. I’m glad you found it useful! While lots of things have changed in WordPress in the last few years, most of the core stuff still works 🙂

      Oh, and thanks for pointing out the typo!

Leave a Reply

Your email address will not be published. Required fields are marked *