Your numbered pages are built using the "for" loop in the above code. I don't have access to your full code but I'm guessing some simple change to that line will make the difference.
PHP Code:
for($i = $page-2; $i <= $page+8; $i++){
To explain the way "for" loops work, there are 3 variables, usually expressed as ($i = beginning number; $i = ending number; $i = increment in counting).
Your orginal code counted from 1 ($i = 1) to greater than or equal to the total number of pages ($i <= $total_pages) using increments of 1 ($i++).
I changed it to count from current page - 2 pages ($i = $page-2) to greater than or equal to current page plus 8 pages ($i <= $page+8) using increments of 1 ($i++)
My code is not going to be perfect but it may get you started in the right direction.
Bookmarks