Fix total pages for custom limit and offset