phpwordpresswordpress-theming

Get Authors Randomly


how to get authors details and author page permalink randomly. I have checked the new get_users() function for wordpress which is returning the author but i can not sorting them randomly.

here is the site i am using the code: http://citystir.com

Any help?


Solution: Thanks to theomega i have solved the isse. Here is the code just for community sharing:

$args = array('role' => 'author');

    $authors = get_users($args);
    shuffle($authors);
    $i = 0;
     foreach ($authors as $author): 
           if($i == 4) break;
           //do stuff
           $i++;
         endforeach;

Did not set the limit on the $args because i need the shuffle in all users. Hope it will help someone out there, in the wild. :D Thanks!


Solution

  • Try

    $users = get_users('ciriteria');
    shuffle($users)
    //users is now shuffled
    

    Using the PHP Shuffle-Function.