SHARE
TWEET

Untitled

a guest Oct 25th, 2018 113 Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
  1. <?php
  2.     if ( get_query_var( 'paged' ) ) {
  3.         $paged = get_query_var('paged');
  4.     }elseif( get_query_var( 'page' ) ) {
  5.         $paged = get_query_var( 'page' );
  6.     }else{
  7.         $paged = 1;
  8.     }
  9.  
  10.     $per_page = 3;
  11.     $number_of_terms = wp_count_terms( 'series' ); // This counts the total number terms in the taxonomy with a function)
  12.     $paged_offset = ($paged - 1) * $per_page;
  13.  
  14.     $args = array(
  15.         'orderby'           => 'ID',
  16.         'order'             => 'DESC',
  17.         'hide_empty'        => 0,
  18.         'number'            => $per_page,
  19.         'offset'            => $paged_offset
  20.     );  
  21.  
  22.     $terms = get_terms('series', $args);  
  23.  
  24.     foreach($terms as $term){ ?>
  25.  
  26.         <div class="block_item article">
  27.             <div  class="article_image" style="background: url('<?php the_field('series_artwork', $term); ?>'); background-size: cover; background-position: 50%;"></div>
  28.             <h4 class="section_label"><?php the_field('date', $term); ?></h4>
  29.             <div class="block_item_content">
  30.                 <h3><?php echo $term->name; ?></h3>
  31.                 <p><?php echo $term->description; ?></p>
  32.                 <a href="<?php echo get_term_link($term->slug, 'series'); ?>" class="button_styling">
  33.                     Read More
  34.                 </a>
  35.             </div>
  36.         </div>
  37.  
  38.     <?php }
  39.  
  40.     $big = 999999999; // need an unlikely integer
  41.     $cur_page = max( 1, $paged );
  42.     $num_pages = ceil( $number_of_terms / $per_page );
  43.     $links = paginate_links(
  44.         array(
  45.             'base'    => str_replace( $big, '%#%', esc_url( get_pagenum_link( $big ) ) ),
  46.             'format'  => '/page/%#%',
  47.             'current' => $cur_page,
  48.             'total'   => $num_pages,
  49.             'prev_text' => __(''),
  50.             'next_text' => __('')
  51.         )
  52.     );
  53.  
  54.     // If there are links to paginate, display the pagination.
  55.     if ( $links ) {
  56.         $before = '<span>Page '. $cur_page .' of ' . $num_pages . '</span>';
  57.         echo '<div class="pagination">' . $before . ' ' . $links . '</div>';
  58.     }
  59. ?>
RAW Paste Data
We use cookies for various purposes including analytics. By continuing to use Pastebin, you agree to our use of cookies as described in the Cookies Policy. OK, I Understand
 
Top