Hidden posts are appearing in blog via page.find(x).children

Iā€™m using the following code to retrieve the 4 most recent posts from my blog and display them on the homepage, however it is displaying posts with published: falseand visible: false set. Any suggestions on how to stop these showing up? Thanks :slight_smile:

{% set blogs = page.find('/blog').children.order('date', 'desc').slice(0, 4)  %}
{% include 'partials/blogGrid.html.twig' with { 'collection': blogs, 'offset': 0, 'limit': 4} %}

(Note: hidden posts do not display on the blog page.)

just do this:

% set blogs = page.find('/blog').children.visible.order('date', 'desc').slice(0, 4)  %}
1 Like

Beautiful! Thanks heaps!! :smiley: