Am not sure if this would help but i find this somewhere in the site a couple of months ago.
=========
<?php
/*
Plugin Name: Page Navigation
Plugin URI: https://www.lesterchan.net/portfolio/programming.php
Description: Adds A Page Navigation To Your WordPress. Please Make Sure Post Paged Is Turned On.
Version: 1.2
Author: GaMerZ
Author URI: https://www.lesterchan.net
*/
function page_navigation($before=”, $after=”, $prelabel=’?? ‘, $nxtlabel=’ ??’) {
global $p, $what_to_show, $request, $posts_per_page, $wpdb;
global $HTTP_SERVER_VARS, $paged;
global $querystring_start, $querystring_equal, $querystring_separator;
if (empty($p) && ($what_to_show == ‘paged’)) {
$nxt_request = $request;
$whichpage = $_GET[‘paged’];
if(empty($whichpage)) $whichpage = 1;
$qstr = $HTTP_SERVER_VARS[‘QUERY_STRING’];
if (!empty($qstr)) {
$qstr = preg_replace(“/&paged=\d{0,}/”,””,$qstr);
$qstr = preg_replace(“/paged=\d{0,}/”,””,$qstr);
} elseif (stristr($HTTP_SERVER_VARS[‘REQUEST_URI’], $HTTP_SERVER_VARS[‘SCRIPT_NAME’] )) {
if (” != $qstr = str_replace($HTTP_SERVER_VARS[‘SCRIPT_NAME’], ”, $HTTP_SERVER_VARS[‘REQUEST_URI’]) ) {
$qstr = preg_replace(“/^\//”, “”, $qstr);
$qstr = preg_replace(“/paged\/\d{0,}\//”, “”, $qstr);
$qstr = preg_replace(“/paged\/\d{0,}/”, “”, $qstr);
$qstr = preg_replace(“/\/$/”, “”, $qstr);
}
}
if ($pos = strpos(strtoupper($request), ‘LIMIT’)) {
$nxt_request = substr($request, 0, $pos);
}
$nxt_result = $wpdb->query($nxt_request);
$numposts = $wpdb->num_rows;
$max_page = ceil($numposts / $posts_per_page) ;
echo $before.’Pages (‘.$max_page.’) : <b>’;
if ($whichpage >= 4)
echo ‘?? First … ‘;
previous_posts_link($prelabel);
for($i = $whichpage – 2 ; $i <= $whichpage +2; $i++) {
if ($i >= 1 && $i <= $max_page) {
if($i == $whichpage)
echo ‘[‘.$i.’] ‘;
else
echo ‘‘.$i.’ ‘;
}
}
next_posts_link($nxtlabel, $max_page);
if (($whichpage+2) < ($max_page))
echo ‘ … Last ??‘;
echo ‘</b>’.$after;
}
}
?>