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

1 Answer 1


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

  • Works just like magic! thanks a lot @Mridul Aggarwal!
    – gil hamer
    Jan 2, 2013 at 14:35

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.