Forums

Order: Option for Random (4 posts)

  1. Cornflower Design
    Member
    Posted 8 months ago #

    Within built-in WordPress functions, such as get_posts() and get_users(), it would be very useful to have an additional value for the order parameter to allow results to be returned in a random order. For example:

    <?php get_users('role=author&number=3&order=RAND); ?>

  2. alchymyth
    The Sweeper
    Posted 8 months ago #

    there is some instruction in the codex for get_posts()
    http://codex.wordpress.org/Template_Tags/get_posts#Random_posts

    not sure with get_users() - for instance, have you tried to use 'orderby=rand'?

    (if it is not directly mentioned in the codex, does not mean it would not work)

  3. Cornflower Design
    Member
    Posted 8 months ago #

    Thanks. I hadn't spotted that the rand value was available for the orderby parameter within get_posts().

    Looking through wp-includes/user.php it's deffinetely not an option for get_users().

  4. Cornflower Design
    Member
    Posted 8 months ago #

    rand doesn't appear to be a valid value within get_pages() either. It would be helpful if the standard set of properties were consistant throughout these functions.

Reply

You must log in to post.

About this Topic