Last active
April 18, 2020 11:25
-
-
Save joviczarko/7784bd3c3637412f4fe7ce0cb7629a67 to your computer and use it in GitHub Desktop.
Wordpress numbered pagination
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 | |
/** | |
* Set text domain | |
*/ | |
function get_text_domain() { | |
return 'textdomain'; | |
} | |
/** | |
* Custom post navigation function. | |
*/ | |
function dwply_posts_navigation() { | |
global $wp_query; | |
$big = 999999999; // need an unlikely integer | |
echo '<section class="posts-navigation">'; | |
echo '<div class="container">'; | |
echo '<nav id="pagination">'; | |
echo paginate_links( array( | |
'base' => str_replace( $big, '%#%', esc_url( get_pagenum_link( $big ) ) ), | |
'format' => '/page/%#%', | |
'end_size' => 0, | |
'mid_size' => 4, | |
'type' => 'plain', | |
'current' => max( 1, get_query_var('paged') ), | |
'prev_text' => __('« Prev', get_text_domain()), | |
'next_text' => __('Next »', get_text_domain()), | |
'total' => $wp_query->max_num_pages | |
) ); | |
echo '</nav>'; | |
echo '</div>'; | |
echo '</section>'; | |
} |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment