Frontend/Backend Pagination bug for 6 pages.

Fixed problem for backend and frontend when num_pages was 6, it showed a 7 button.