Created
September 6, 2014 03:11
-
-
Save setuix/53206c254d95cf987680 to your computer and use it in GitHub Desktop.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
// Pagination for a WordPress loop | |
$list = new WP_Query( $query_args ); | |
$pagination = array( | |
'base' => str_replace( 99999, '%#%', get_pagenum_link( 99999 ) ), | |
'format' => '?paged=%#%', | |
'current' => max( 1, get_query_var( 'paged' ) ), | |
'total' => $list->max_num_pages, | |
'next_text' => 'next', | |
'prev_text' => 'previous' | |
); | |
echo '<div class="pagination primary-links">' . paginate_links( $pagination ) . '</div>'; | |
// Pagination for anything | |
$list = range(1, 100); | |
$items_per_page = 12; | |
$pagination = array( | |
'base' => get_bloginfo( 'url' ) . '/mypage/%_%', | |
'format' => '?paged=%#%', | |
'current' => $_GET['current_page'], | |
'total' => ceil( max($list) / $items_per_page ), | |
'next_text' => 'go forth', | |
'prev_text' => 'go back' | |
); | |
echo '<div class="pagination primary-links">' . paginate_links( $pagination ) . '</div>'; |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment