Fetch all five posts in one query, store the result in a variable and take one each time you want to show an advertisement.
Now you cannot get duplicates, and more important: you save four queries.
Fetch all five posts in one query, store the result in a variable and take one each time you want to show an advertisement.
Now you cannot get duplicates, and more important: you save four queries.