Scheduled blog posts and Feed Plugin

In order to ‘schedule’ future blog posts that become visible automatically, I am setting the published date as needed, making the post visible and my template (Manila) is working as expected. However the RSS feed (provided by the feed plugin) filters only on post visibility so shows these future posts immediately.

Is this because the plugin is expecting a different field name for ‘date_published’ or does it just not do this filtering?

I’m afraid my PHP understanding is pretty basic so I can’t tell so I’d be grateful for any help.


1 Like

This should work (untested):

Change in feeds template.php

<?php foreach($items as $item): ?>
  <?php if ($item->date() >= time()) : ?>
  <?php endif; ?>
<?php endif preach; ?>

I’m using a filter for that:

page('blog')->children()->visible()->filterBy('date', '<=', time())
1 Like

@mauricehh: Thanks so much - I was just trying to implement that (and failing) myself!

@flokosiol: Thanks so much for the response. The problem with that approach is that in order to fix the ‘lastBuildDate’ issue with the Feed Plugin ( I’m referencing the modified date of the first item prior to this foreach loop, so that value remains wrong.

Amazed by the support here. Hope I can reciprocate at some point. Thanks all!

1 Like

That’s much better, @mauricehh

I struggled to apply the filter and delved into my theme’s code for some guidance. I’ve ended up with this replacing my blog-feed template:

echo page('blog')
        ->filter(function($child) {
            return (time() - strtotime($child->date_published())) >= 0;
            'title'       => $page->title(),
            'description' => $page->description(),
            'link'        => 'blog'

Thanks again!