Skip to content

Instantly share code, notes, and snippets.

@cameronbaney
Last active August 29, 2015 14:07
Show Gist options
  • Save cameronbaney/e199801cdb14d58f46b5 to your computer and use it in GitHub Desktop.
Save cameronbaney/e199801cdb14d58f46b5 to your computer and use it in GitHub Desktop.
WordPress Pagination
<?php
$paged = (get_query_var('paged')) ? get_query_var('paged') : 1;
$query = new WP_Query(array('post_type'=>$type,'posts_per_page'=>'5','orderby'=>'date','order'=>'DESC','paged'=>$paged));
?>
<div class="pagination">
<?php
$big = 999999999;
echo paginate_links( array(
'base' => str_replace( $big, '%#%', esc_url( get_pagenum_link( $big ) ) ),
'format' => '?paged=%#%',
'current' => max( 1, get_query_var('paged') ),
'total' => $query->max_num_pages, // Make sure the variable is the same as the WP_Query Variable
'show_all' => False,
'end_size' => 1,
'mid_size' => 2,
'prev_next' => True,
'prev_text' => __('<i class="icon-arw-left"></i>'),
'next_text' => __('<i class="icon-arw-right"></i>'),
'type' => 'plain',
'add_args' => False,
'add_fragment' => '',
'before_page_number' => '',
'after_page_number' => ''
) );
?>
</div>
<?php
$big = 999999999;
global $wp_query;
echo paginate_links( array(
'base' => str_replace( $big, '%#%', esc_url( get_pagenum_link( $big ) ) ),
'format' => '?paged=%#%',
'current' => max( 1, get_query_var('paged') ),
'total' => $wp_query->max_num_pages,
'show_all' => False,
'end_size' => 1,
'mid_size' => 2,
'prev_next' => True,
'prev_text' => __('<i class="icon-arw-left"></i>'),
'next_text' => __('<i class="icon-arw-right"></i>'),
'type' => 'plain',
'add_args' => False,
'add_fragment' => '',
'before_page_number' => '',
'after_page_number' => ''
) );
?>
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment