I have many users on my website, out of some has status "elite". I am saving this status in meta key/value for each user ('meta_key' => 'elite_member', 'meta_value' => '1').

I want to display randomly 2 user profiles in rotation on my site home page which has status "elite" so that each user profiles will appear same no. of times in rotation. I am able to get all the users with meta_key "elite" and meta_value="1"

$elite_members=get_users(array('meta_key' => 'elite_member', 'meta_value' => '1'));

But I am not able to get how to display 2 user profiles in rotation so that each user will get same no. of chance to appear on home page.

1 Answer 1


As get_users does not support the order_by random, you could shuffle the array after calling the function.

If you want to distribute it even, you could make another meta_value, where you store the number of appearances per user, and call the get_users with this new meta_key in ascending sort_order - this way the user with the least appearances will be shown on the homepage.

  • could u pls write example of how to call get_users with new meta_key in ascending sort_order? I am not able to do that after looking the get_users parameters.Thanks
    – Ram
    Nov 28, 2012 at 8:07

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.