Modified pagination for all templates