I am using a custom post type to manage adverts on a website. There are 3 identical ad spaces on each page, output via WP Query.
Could someone please suggest, on a high level, an approach to show 3 different posts per page load, but not repeat posts shown from previous page (could be sequential)?
So for example, if there were 9 adverts (posts) in the custom post type:
- User lands on website page > adverts 1, 2 and 3 are visible.
- User navigates to another page > adverts 4, 5 and 6 are visible.
- User navigates to a third page > adverts 7, 8, and 9 are visible.
- User navigates to another page > adverts 1, 2 and 3 are shown again.
I don't need the answer to provide the code, necessarily; just an explanation of how one might approach the solution.
The point of doing this is to make sure each advert gets an (almost) equal number of impressions for each visitor, but I cant use 'orderby' => 'rand'
because nCr (n=9,r=3) probability (which is how I've currently implemented it) means that the same adverts can be shown on two successive page loads and the client doesn't want that.
I am considering a JS cookie as the only way to keep a counter and querying the posts via AJAX, but perhaps there is another way?
Many thanks in advance.