Here’s how to add numeric pagination on your WordPress pages.
Add this code to functions.php.
function pagination($pages = '', $range = 4) {
$showitems = ($range * 2)+1;
global $paged;
if(empty($paged)) $paged = 1;
if($pages == '') {
global $wp_query;
$pages = $wp_query->max_num_pages;
if(!$pages) {
$pages = 1;
}
}
if(1 != $pages) {
echo 'Page' . $paged . ' of ' . $pages . ' ';
if($paged > 2 && $paged > $range+1 && $showitems < $pages) echo '<< First';
if($paged > 1 && $showitems < $pages) echo '< Previous';
for ($i=1; $i <= $pages; $i++) {
if (1 != $pages &&( !($i >= $paged+$range+1 || $i <= $paged-$range-1) || $pages <= $showitems )) {
echo ($paged == $i)? '' . $i . '' : '' . $i . '';
}
}
if ($paged < $pages && $showitems < $pages) echo 'Next >';
if ($paged < $pages-1 && $paged+$range-1 < $pages && $showitems < $pages) echo 'Last >>';
echo '';
}
}
To display, comment out ‘the_post_navigation’ function and add the ‘pagination’ function instead in your template files.
//the_posts_navigation();
pagination();
Code courtesy of webdesignsun.