If the $page parameter is specified, this function will additionally check if the query is for one of the pages specified.