Take the 2-minute tour ×
WordPress Development Stack Exchange is a question and answer site for WordPress developers and administrators. It's 100% free, no registration required.

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.

share|improve this question
    
Show your code. –  kaiser Oct 28 '11 at 0:37
    
@kaiser, Hi I included the code. Thank you. –  user1893 Oct 28 '11 at 13:25
add comment

1 Answer

up vote 2 down vote accepted
$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

share|improve this answer
    
Thank you ljaas. Now I have a base to work with. I appreciate it. –  user1893 Oct 28 '11 at 16:32
add comment

Your Answer

 
discard

By posting your answer, you agree to the privacy policy and terms of service.

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