Let's say you have a list of Book elements (like here), each of which have a title, author and category fields. Now if on a page you want to show a filtered list of only the books from category Fiction, you can do this:
{% elementscontext category="Fiction" %}
<h2>Fiction books</h2>
<ul>
{% for fiction_book in elements %}
<li><b>{{ fiction_book.title }}</b> by {{ fiction_book.author }}</li>
{% endfor %}
</ul>
{% endelementscontext %}
This will give you only the books from category Fiction:
Fiction books
The Abilene Trail by Ralph Compton and Dusty Richards
Across the Nightingale Floor by Liam Hearn
The accidental by Ali Smith
This website uses cookies
We use cookies to ensure that we give you the best experience on our website. By clicking "Accept all" you agree to using analytical cookies. By clicking "Allow only necessary" you refuse the use of analytical cookies. You can change your cookie preferences at any time.