WordPress Development Stack Exchange is a question and answer site for WordPress developers and administrators. Join them; it only takes a minute:

Sign up
Here's how it works:
  1. Anybody can ask a question
  2. Anybody can answer
  3. The best answers are voted up and rise to the top

I was having an issue the other day and successfully got a very good answer which helped me alot achive what I wanted. this is the post which I created and have all the correspondence:


The answer was kindly contributed courtesy of @Sagive SEO

This script currently displays all authors in an order of most posts written.

I would like to change it to simply display all authors randomly regardless of how many posts they wrote.

Hope to get an answer, thanks a lot Gil

share|improve this question
up vote 1 down vote accepted

What you need here is to shuffle all the array elements & then display them. But since php's shuffle() function doesn't preserve array key associations, here's a version that does.

function shuffle_assoc(&$array) {
    $keys = array_keys($array);
    foreach($keys as $key) {
        $new[(string)$key] = $array[$key];
    $array = $new;
    return true;

Add this function somewhere in your functions.php & replace arsort($authorsArray); with shuffle_assoc($authorsArray); in the code suggested in the previous question

share|improve this answer
Works just like magic! thanks a lot @Mridul Aggarwal! – gil hamer Jan 2 '13 at 14:35

Your Answer


By posting your answer, you agree to the privacy policy and terms of service.

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