Skip to content
● Meet Grav Guard: keep every Grav site you run secure and up to date, all from one place. Free for up to 3 sites. Read more →

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

Started by Muut Archive 10 years ago · 2 replies · 630 views
10 years ago

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 :)

TWIG
{% 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.)

10 years ago

just do this:

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

Suggested topics

Topic Participants Replies Views Activity
Archive · by Muut Archive, 10 years ago
1 720 2 weeks ago
Archive · by Deleted User, 9 years ago
0 3077 9 years ago
Archive · by Muut Archive, 9 years ago
2 2017 9 years ago
Archive · by Muut Archive, 9 years ago
2 5374 9 years ago
Archive · by Muut Archive, 9 years ago
1 4167 9 years ago