Autopublish post

I have a blog website with different category pages. Currently, we need to manually publish posts that are scheduled for a future date. I would like to automate this process so that posts set with a future publish date go live automatically on the website.

I’d appreciate your help or any suggestions you might have.

That is typically done via a script that is triggered via a cron job

1 Like

@texnixe Wouldn’t that also work with a controller if he set the date in the article to a date in the future?

/site/controllers/blog.php

<?php

return function ($page) {
    $posts = $page->children()
        ->listed()
        ->filter(function ($post) {
            return $post->date()->toDate() <= time();
        })
        ->sortBy('date', 'desc');

    return compact('posts');
};

But with your example, the page would already be listed, not a draft, and that would not apply to a single page.

My colleague and I have a plugin for that, which must be triggered via a cronjob. It has a Webhook URL for that. It comes with two panel fields to enable/disable auto-publishing and a date-time-field for the moment to publish. We haven’t published the plugin currently, but if there is a need, we could do so.

1 Like

That would be awesome! I’ve been contemplating building one myself, but haven’t had the time yet.

Hi @mauricehh
It would be great if you could share the plugin file with me so I can try implementing it.

Alright, I’ll give you an update once the plugin is available

1 Like

I just put it online: GitHub - konzentrik/kirby-autopublish: This Kirby plugin will autopublish a page when a toggle is enabled and a date set.
Please let me know if something is unclear or not working.

2 Likes