Filter collection by taxonomy/category terms, in antlers #8331
Unanswered
kylef-fotf
asked this question in
Q&A
Replies: 1 comment 1 reply
-
Start with the category and loop through the entries inside it. Try the Taxonomy tag!On Jun 20, 2023, at 5:43 PM, kylef-fotf ***@***.***> wrote:
I am trying to build a simple entries index called articles.
The articles index needs to display a list of articles separated by categories.
E.g.
Category A
Article 1
Article 2
Category B
Article 3
Article 4
Category C
Article 5
Article 6
I want to get the collection of articles that have a specific category assigned to it. Articles can have 1 or more categories.
This is what I'm doing right now:
articles/index.antlers.html
<div class="grid grid-cols-3 grid-rows-3">
{{ partial:articles/list limit="2" categories="cat-a" }}
{{ partial:articles/list limit="2" categories="cat-b" }}
{{ partial:articles/list limit="2" categories="cat-c" }}
</div>
articles/_list.antlers.html
{{ collection:articles :limit="limit" :categories="categories" }}
{{ partial:articles/single :uri="uri" :title="title" :author="author" :categories="categories" }}
{{ /collection:articles }}
articles/_single.antlers.html
<a href="{{ uri }}">
<div>
<div class="">
<h4 class="">{{ title }}</h4>
<small class="">
<span class="">by {{ author }}</span>
</small>
<small class="">
{{if categories }}
{{ categories }}
<span>{{ title }}</span>
{{ /categories }}
{{ /if }}
</small>
</div>
</div>
</a>
This does not restrict article fetching to a specific category as desired. What can i do to make this work?
—Reply to this email directly, view it on GitHub, or unsubscribe.You are receiving this because you are subscribed to this thread.Message ID: ***@***.***>
|
Beta Was this translation helpful? Give feedback.
1 reply
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Uh oh!
There was an error while loading. Please reload this page.
-
I am trying to build a simple entries index called articles.
The articles index needs to display a list of articles separated by categories.
E.g.
Category A
Category B
Category C
I want to get the collection of articles that have a specific category assigned to it. Articles can have 1 or more categories.
This is what I'm doing right now:
articles/index.antlers.html
articles/_list.antlers.html
articles/_single.antlers.html
This does not restrict article fetching to a specific category as desired. What can i do to make this work?
Beta Was this translation helpful? Give feedback.
All reactions