First, calculate the number of whole days from your start date, then take the modulus of this and the total number of posts in ‘products’. This will give a ‘post number’ which you can use in the loop to show only the relevant post.
So, if you have three posts $days_elapsed % $post_count
would look like:
| days | mod |
--------------
| 0 | 0 |
| 1 | 1 |
| 2 | 2 |
| 3 | 0 |
| 4 | 1 | etc...
Since the post index number (post->current_post
) starts at zero, you can use an if statement to display the correct post.
$start_date = new DateTime("2016-05-18");
$now = new DateTime("now");
$days_elapsed = $now->diff($start_date)->format("%a");
$args = array (
'post_type' => array( 'products' ),
'order' => 'ASC',
'orderby' => 'title',
);
$query = new WP_Query( $args );
if ( $query->have_posts() ) {while ( $query->have_posts() ) {$query->the_post();
if ($post->current_post == $days_elapsed % $query->post_count) {
the_content();
}
}
}
Note: this is untested, but should get you started. There may also be a more elegant way to do this than loop through all the posts in products