wordpress 3a displaying author lists with pagination

Solutions on MaxInterview for wordpress 3a displaying author lists with pagination by the best coders in the world

showing results for - "wordpress 3a displaying author lists with pagination"
Lennard
03 Apr 2019
1<?php 
2$number   = 10;
3$paged    = (get_query_var('paged')) ? get_query_var('paged') : 1;
4$offset   = ($paged - 1) * $number;
5$users    = get_users();
6$query    = get_users('&offset='.$offset.'&number='.$number);
7$total_users = count($users);
8$total_query = count($query);
9$total_pages = intval($total_users / $number) + 1;
10 
11echo '<ul id="users">';
12 
13foreach($query as $q) { ?>
14   
15  <li class="user clearfix">
16    <div class="user-avatar">
17      <?php echo get_avatar( $q->ID, 80 ); ?>  
18    </div>
19    <div class="user-data">
20 
21      <h4 class="user-name">
22        <a href="<?php echo get_author_posts_url($q->ID);?>">
23          <?php echo get_the_author_meta('display_name', $q->ID);?>
24        </a>
25      </h4>
26 
27      <?php if (get_the_author_meta('description', $q->ID) != '') : ?>
28        <p><?php echo get_the_author_meta('description', $q->ID); ?></p>
29      <?php endif; ?>
30 
31    </div>
32  </li>
33 
34<?php } 
35 
36echo '</ul>';
37 
38?>
39 
40<?php
41if ($total_users > $total_query) {
42echo '<div id="pagination" class="clearfix">';
43echo '<span class="pages">Pages:</span>';
44  $current_page = max(1, get_query_var('paged'));
45  echo paginate_links(array(
46    'base' => get_pagenum_link(1) . '%_%',
47    'format' => 'page/%#%/',
48    'current' => $current_page,
49    'total' => $total_pages,
50    'prev_next'    => false,
51    'type'         => 'list',
52    ));
53echo '</div>';
54?>
55
similar questions