Daily drip of posts – based on user ‘startData’ – ordered oldest to newest


I would like to “Drip” lessons for my class – 1 a day. In the index for the lessons, on the first day, you would see the first lesson, and then on the second day, the second and first lesson, etc. – with today’s lesson at the top (shown in the diagram).

I’m checking the current user – and finding out what ‘team’ they are on. that team has a start_date – and so I can compare the start_date with today’s date and get the difference. That’s going well.

<?php $args = array(
  'post_type' => 'lesson',
  'orderby' => 'post_date', // or date?
  'order'=> 'ASC',
  'posts_per_page' => daysAvailable(), // difference between today/start date?
  // if there are 100+ lessons... and I only need  5 - 
  // then I should only grab 5 here...
); ?>

This gets the other end of the array. I just want the oldest/ lesson-001, 002 etc.

With many combinations of reversing the array – and trying to get only a certain number – it’s so slippery! and I always come up with an unexpected span of dates!

I drew up a quick proof of concept here: https://codepen.io/sheriffderek/pen/0d0237f0c352a8b42527cdbd4bff9c0e?editors=0011 – but I feel like I’m fighting the framework. So, before I go any further… What do you think? What query options should I be using?

enter image description here

(just to clarify – those grayed out lessons are never printed to the HTML)

, sheriffderek 4 years 2020-03-26T16:52:45-05:00 0 Answers 133 views 0

Leave an answer