How to use “offset” to paginate get_users?

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.

Read More

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.

Related posts

Leave a Reply

1 comment

  1. $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