1

Is is possible to paginate the get_users function with the "offset" parameter?

I have complete my custom query of users for my list and now I need to paginate the results into multiple pages.

Here is my sample code:

<ul>
    <?php

    $args = array(
        'meta_key' => 'jabber',
        'meta_value' => 'User Name',
        'meta_compare' => 'LIKE',
        'order' => 'ASC',
        'count_total' => true,
        'fields' => 'all',
      );


    $blogusers = get_users($args_1);
    foreach ($blogusers as $user) {

        $user_id = $user->ID; 
        $user = get_userdata($user_id);

          echo '<li class="provider-list prov-list-gradient">' . $user->display_name . '</li>';

    }
    ?>

    </ul>

If there's anyone you can give some advice I would appreciate it.

Thanks in advanced.

  • Show your code. – kaiser Oct 28 '11 at 0:37
3
$args = array("role" => "subscriber", "number" => 10);

get_users($args); //First 10 Users with the Role Subscriber

$args['offset'] = 10;

get_users($args); //10th to 20th Users with the Role Subscriber

and so on.

Offset = page * number

  • Thank you ljaas. Now I have a base to work with. I appreciate it. – user1893 Oct 28 '11 at 16:32

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service, privacy policy and cookie policy

Not the answer you're looking for? Browse other questions tagged or ask your own question.