Advertisement
wdtobibur

Custom post pagination

Oct 21st, 2018
82
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
PHP 0.72 KB | None | 0 0
  1.       https://stackoverflow.com/questions/41738362/how-to-include-pagination-in-a-wordpress-custom-post-type-query          
  2.  
  3. <?php
  4.                     $total_pages = $loop->max_num_pages;
  5.  
  6.                 if ($total_pages > 1){
  7.                     $current_page = max(1, get_query_var('paged'));
  8.                     echo paginate_links(array(
  9.                         'base' => get_pagenum_link(1) . '%_%',
  10.                         'format' => '/page/%#%',
  11.                         'current' => $current_page,
  12.                         'total' => $total_pages,
  13.                         'prev_text'    => __('« prev'),
  14.                         'next_text'    => __('next »'),
  15.                     ));
  16.     }    
  17.                 ?>
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement