Advertisement
Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- <?php
- if ( get_query_var( 'paged' ) ) {
- $paged = get_query_var('paged');
- }elseif( get_query_var( 'page' ) ) {
- $paged = get_query_var( 'page' );
- }else{
- $paged = 1;
- }
- $per_page = 3;
- $number_of_terms = wp_count_terms( 'series' ); // This counts the total number terms in the taxonomy with a function)
- $paged_offset = ($paged - 1) * $per_page;
- $args = array(
- 'orderby' => 'ID',
- 'order' => 'DESC',
- 'hide_empty' => 0,
- 'number' => $per_page,
- 'offset' => $paged_offset
- );
- $terms = get_terms('series', $args);
- foreach($terms as $term){ ?>
- <div class="block_item article">
- <div class="article_image" style="background: url('<?php the_field('series_artwork', $term); ?>'); background-size: cover; background-position: 50%;"></div>
- <h4 class="section_label"><?php the_field('date', $term); ?></h4>
- <div class="block_item_content">
- <h3><?php echo $term->name; ?></h3>
- <p><?php echo $term->description; ?></p>
- <a href="<?php echo get_term_link($term->slug, 'series'); ?>" class="button_styling">
- Read More
- </a>
- </div>
- </div>
- <?php }
- $big = 999999999; // need an unlikely integer
- $cur_page = max( 1, $paged );
- $num_pages = ceil( $number_of_terms / $per_page );
- $links = paginate_links(
- array(
- 'base' => str_replace( $big, '%#%', esc_url( get_pagenum_link( $big ) ) ),
- 'format' => '/page/%#%',
- 'current' => $cur_page,
- 'total' => $num_pages,
- 'prev_text' => __(''),
- 'next_text' => __('')
- )
- );
- // If there are links to paginate, display the pagination.
- if ( $links ) {
- $before = '<span>Page '. $cur_page .' of ' . $num_pages . '</span>';
- echo '<div class="pagination">' . $before . ' ' . $links . '</div>';
- }
- ?>
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement