Filtering promoted items on the home page by category in custom theme | Community
Skip to main content

Filtering promoted items on the home page by category in custom theme

  • October 27, 2021
  • 3 replies
  • 0 views

Marc17

I want to have separate sections on the home page of my zendesk theme for promoted articles. I thought I could use the filter helper to do this like so.

{{#each (filter promoted_articles on="category" equals="360001836433")}}
<li class="tab-articles__item">
<a class="tab-articles__title" href="{{url}}">{{title}}</a>
<p class="tab-articles__discr">{{excerpt body characters=50}}</p>
</li>
{{/each}}

But nothing shows up in the list, even though I have promoted articles in that category.

What is the correct way of doing this?

3 replies

Ifra
  • October 28, 2021

@Marc, take a look at the given code:

 

{{#each categories}}
{{#is id 360002556788}} // Category ID which have only promoted articles
{{#each sections}}

<h1>{{name}}</h1>
{{#if articles}}
{{#each articles}}
{{#if promoted}}

<li class="promoted-articles-item">
<a href="{{url}}">
{{title}}
</a>
</li>

{{/if}}
{{/each}}
{{/if}}

{{/each}}
{{/is}}
{{/each}}

 

Thanks


Marc17
  • Author
  • October 29, 2021

Awesome, that worked, thank you!


Ifra
  • October 29, 2021

Woohoo!