mercredi 4 novembre 2015

How to random order a user list with get_users

I actually have a "users" page ordered by post_count. I'm wondering if is possible to order the list randomly. I know that the get_usersfunction just allows ordering by 'ID', 'login', 'nicename', 'email', 'url', 'registered', 'display_name', 'post_count', 'include',or'meta_value'

For get_posts, if I remember well, there is a rand option to achieve this.

Here's the code of my template:

<?php

/*
Template Name: Display Contributors and Authors
*/

    $args = array(
         'role'    => 'contributor',
         'orderby' => 'post_count',
         'order'   => 'DESC'
    );
 
    // only return users with published posts
        $args['has_published_posts'] = true;
    // run the WP_Query
        $contributors = get_users( $args );

    ?>



Aucun commentaire:

Enregistrer un commentaire