Take the 2-minute tour ×
WordPress Development Stack Exchange is a question and answer site for WordPress developers and administrators. It's 100% free, no registration required.

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:

wordpress.stackexchange.com/questions/63060/display-all-authors-and-their-only-one-latest-post

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
add comment

1 Answer

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);
    shuffle($keys);
    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
add comment

Your Answer

 
discard

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.