Skip to content
Grav 2.0 is officially stable. Read the announcement →
Archive

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

Started by Muut Archive 9 years ago · 2 replies · 416 views
9 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.)

9 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 Deleted User, 9 years ago
0 1333 9 years ago
Archive · by Muut Archive, 9 years ago
2 924 9 years ago
Archive · by Muut Archive, 9 years ago
2 4055 9 years ago
Archive · by Muut Archive, 9 years ago
1 2938 9 years ago
Archive · by Muut Archive, 9 years ago
3 1111 9 years ago