I have a blog and I have a field in my frontmatter where I define whether a post is features or not "featured: true/false". I'm looking for a way to find the posts where featured is true and can't seem to find any examples. Any ideas?
Archive
By having a frontmatter setting, you would have to loop over every post and check if header.featured == true.
Something like:
TWIG
<h1>Featured Posts:</h1>
<ul>
{% for p in page.find('/blog').children if p.header.featured == true %}
<li><a href="{{ p.url }}">{{ p.title }}</a></li>
{% endfor %}
</ul>
This is untested but should work :) BTW this was almost exactly the same as this example in the docs.
Log in to reply.
Suggested topics
| Topic | Participants | Replies | Views | Activity |
|---|---|---|---|---|
| 0 | 1360 | 9 years ago | ||
| 2 | 939 | 9 years ago | ||
| 2 | 4069 | 9 years ago | ||
| 1 | 2958 | 9 years ago | ||
| 3 | 1122 | 9 years ago |