Ok buddy add this code to your functions.php
//Will use this function as conditional statement to show or hide our pagination...
function if_show_posts_nav() {
global $wp_query;
return ( $wp_query->max_num_pages > 1 );
}
//This function is responsible for creating numbered navigation
function my_numbered_nav() {
global $wp_query;
/*We need this here to add numbered Pagination used in paginate_links function
SEE: https://codex.wordpress.org/Function_Reference/paginate_links
*/
if ( get_query_var( 'paged' ) ) {
$paged = absint( get_query_var( 'paged' ) );
} elseif ( get_query_var( 'page' ) ) {
$paged = absint( get_query_var( 'page' ) );
} else {
$paged = 1;
}
//structure of "format" depends on whether we're using pretty permalinks
if ( get_option('permalink_structure') ) {
$format = '?paged=%#%';
} else {
$format = 'page/%#%/';
}
$big = 999999999; // need an unlikely integer
$base = $format =='?paged=%#%' ? $base = str_replace( $big, '%#%', esc_url( get_pagenum_link( $big ) ) ) : $base = esc_url( @add_query_arg('paged','%#%') );
echo paginate_links( array(
'base' => $base,
'format' => $format,
'current' => max( 1, $paged ),
'total' => $wp_query->max_num_pages,
'prev_text' => esc_html__( '‹ Prev', 'domain' ),
'next_text' => esc_html__( 'Next ›', 'domain' ),
'end_size' => 1,
'mid_size' => 1,
) );
}
Then use it like so:
<?php if ( if_show_posts_nav() ) : ?>
<div class="navigation">
<?php my_numbered_nav();?>
</div><!--/navigation-->
<?php endif; ?><!--/if_show_posts_nav-->