Only show posts with publish dates in the past

#1

I want to show the latest news posts on my homepage, but only those with a publish date that is not in the future. This is what I have now:

<?php foreach ($articles = $site->children()->listed()->filterBy('template', 'post')->sortBy('date', 'desc')->paginate(50) as $page): ?>

#2

You need to filter them, there is example in the docs

// fetch children with a date in the past
$items = $page->children()->filter(function ($child) {
  return $child->date()->toDate() < time();
});
#3

thanks @jimbobrjames !