add check to prevent plugin from looping over every page when each pages is built