Last active
October 31, 2021 02:37
-
-
Save barbwiredmedia/722d38b42cbdba4a453c to your computer and use it in GitHub Desktop.
Wordpress pagination - paginate links http://codex.wordpress.org/Function_Reference/paginate_links No plugins required. Minor styling needed OR used bootstrap assitance: http://www.ordinarycoder.com/paginate_links-class-ul-li-bootstrap/
This file contains hidden or 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
<?php echo paginate_links( $args ); ?> | |
<!--OR--> | |
<?php | |
//custom paginaiton with styling from bootstrap | |
function custom_pagination() { | |
global $wp_query; | |
$big = 999999999; // need an unlikely integer | |
$pages = 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, | |
'prev_next' => false, | |
'type' => 'array', | |
'prev_next' => TRUE, | |
'prev_text' => __('«'), | |
'next_text' => __('»'), | |
) ); | |
if( is_array( $pages ) ) { | |
$paged = ( get_query_var('paged') == 0 ) ? 1 : get_query_var('paged'); | |
echo '<ul class="pagination">'; | |
foreach ( $pages as $page ) { | |
echo "<li>$page</li>"; | |
} | |
echo '</ul>'; | |
} | |
}?> | |
<?php echo custom_pagination();?> |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment