I building a WorPress site that is going to run ads.

The ads will display before and after a visitor interacts with certain parts of the site.

Each ad is a post from a custom post type. The function pulls 4 ads at a time and displays them on the site for x amount of seconds. After a set amount of time a new query is made to display 4 new ads again.

What I want to do is to show the same ads that was queried the first time, the second time.

There is nothing "wrong" with my code. Its a "simple" query. But I don't have an easy solution for this in my head. So I am wondering if there is a method to do this, that does not involve "starting over" again.

Could i somehow save the ID's and make sure the next query only pick those, or is it another smoother way of doing it?

  • 1
    Is there a page refresh between? If not, can't you use javascript+css with timer to toggle the ads without making a new WP_Query? Add a CSS class for display:none when the ads are hidden? – birgire Dec 31 '18 at 7:56

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service, privacy policy and cookie policy

Browse other questions tagged or ask your own question.