Change featured post automatically

Hey All

I’ve recently moved a site over from WordPress to Ghost. It’s a basic quotes website.

On the home page, I have a “quote of the day” which I’m changing manually by featuring the post.

Is there a way to do this automatically using JS? To change that post every 24 hours? It can just be a random post but the same post shouldn’t be repeated.

Alternatively, is there something I can do via Zapier?

Thanks in advance for any suggestions.

Matt

Hey @Mattches. Best way I think would be to use the Ghost Content API with JavaScript to pull out a random post. By default you could set a quote but then let the JS take over and replace it with a randomly picked one. There’s a good starting piece of code here, you’ll need to get all the posts as an array and then randomly pick from that array:
https://ghost.org/docs/api/v2/javascript/content/#working-example

I can provide an example if you’re unable to work it out :slightly_smiling_face:

Hey @DavidDarnes Thanks for the info. Let me try to work it out on my own first as a little challenge. I’ll let you know if I run into any difficulty.

Thanks mate.

1 Like