Add a loop to handle attachment pages