Related posts by author pagination not working on the production site

The code that I’m using has adapted from this example and successfully tested on my localhost but when I pass the site to a live server, the pagination crashes with wordpress permalinks set (/% postname% /) and only works with the default wp permalinks (? p = 123).
The problem is that it doesn’t show me any 404 page, but it also doesn’t let me go to the second or third pages, or any other’s if they exist.