So I'm trying to list my wordpress user id's each time in a random order.
Right now I have this, but for some reason, 'orderby' => 'rand'
is not randomizing the list.
<?php
$args = array(
'meta_key' => 'active',
'meta_value' => 'yes',
'number' => 99999,
'orderby' => 'rand',
);
$my_user_query = new WP_User_Query( $args );
$publishers = $my_user_query->get_results();
if ( ! empty( $publishers ) ): ?>
<?php foreach ( $publishers as $publisher ):
setup_postdata( $publisher )
?>
<?php echo $publisher->ID; ?>
<?php endforeach; ?>
<?php wp_reset_postdata(); ?>
<?php endif; ?>
I have tried 'order' => 'rand'
which is not correct as to my knowledge.
To make sure that the above array works, I have tried:
'order' => 'ASC'
and 'order' => 'DESC'
both worked great.
I assume there's something wrong with my rand code line.
I have also heard that it's possible to use shuffle($users);
, but I have no idea where and how to implement.
Need help.