handle pagination of posts