Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- $paged = ( get_query_var('paged') ) ? get_query_var('paged') : 1;
- $per_page = 9;
- $number_of_series = count( $total_categories );
- $offset = $per_page * ( $paged - 1) ;
- $totalpages = ceil( $number_of_series / $per_page );
- $total_categories_paginated = get_terms( array(
- 'taxonomy' => 'category',
- 'fields' => 'ids',
- 'exclude' => array(608,4003,756),
- 'hide_empty' => false,
- 'offset' => $offset,
- 'number' => $per_page,
- ) );
- function custom_page_navi( $totalpages, $paged, $end_size, $mid_size ) {
- $bignum = 999999999;
- if ( $totalpages <= 1 || $paged > $totalpages ) return;
- return paginate_links( array(
- 'base' => str_replace( $bignum, '%#%', esc_url(get_pagenum_link( $bignum ) ) ),
- 'format' => '',
- 'current' => max( 1, $paged ),
- 'total' => $totalpages,
- 'prev_text' => 'Prev',
- 'next_text' => 'Next',
- 'type' => 'list',
- 'show_all' => false,
- 'end_size' => $end_size,
- 'mid_size' => $mid_size
- ) );
- }
- foreach ($total_categories_paginated as $single_category) {
- // doing my things with every category
- }
- printf( '<nav class="pagination">%s</nav>',
- custom_page_navi( $totalpages, $paged, 3, 3 )
- );
Add Comment
Please, Sign In to add comment