Ease Theme Hard Code Topics on home page

Hi, I really like the way the Ease Theme has the ability to view 5 posts from tags. I have specific tags I want to display on the home page. Is there a way I can do this?

I tried to see if I could do this for one of my tags (“book”, so I wrote below in index.hbs (apologies for the bad code, but I’m not a programmer :nerd_face:

All that happened was ALL the tags didn’t display. Is there a way I can test for specific tags and then perform actions based on the tag expression being true?

{{#get "tags" limit="all"}}
    <div class="topic-feed">
        {{#if "book" includeZero=false}}
            <section class="topic">
                <header class="topic-header">
                    <h2 class="topic-name">
                        <a href="{{url}}">{{name}}</a>
                    </h2>
                </header>
                {{#get "posts" order="published_at asc" filter="tag:{{slug}}" limit="5" as |featured|}}
                    <ul class="topic-article-feed">
                        {{#foreach featured}}
                        <li class="topic-article">
                            <h3 class="topic-article-title">
                                <a class="topic-article-link" href="{{url}}">
                                    {{> "icons/chevron-right"}} {{title}}
                                </a>
                            </h3>
                        </li>
                        {{/foreach}}
                    </ul>
                {{/get}}
                <a class="topic-more" href="{{url}}">Show more →</a>
            </section>
        {{/if}}

{{#if "book" }} is incorrect. The #get will get all the tags, and then you need to loop through them with foreach. I’ll indicate below where you might put your extra logic.

{{#get "tags" limit="all"}}
    <div class="topic-feed">

        {{#foreach tags}}
           {{#match slug "=" "book"}}
            <section class="topic">
                <header class="topic-header">
                    <h2 class="topic-name">
                        <a href="{{url}}">{{name}}</a>
                    </h2>
                </header>
                {{#get "posts" order="published_at asc" filter="tag:{{slug}}" limit="5" as |featured|}}
                    <ul class="topic-article-feed">
                        {{#foreach featured}}
                        <li class="topic-article">
                            <h3 class="topic-article-title">
                                <a class="topic-article-link" href="{{url}}">
                                    {{> "icons/chevron-right"}} {{title}}
                                </a>
                            </h3>
                        </li>
                        {{/foreach}}
                    </ul>
                {{/get}}
                <a class="topic-more" href="{{url}}">Show more →</a>
            </section>
        {{else}}
            {{!-- do something different for tags other than book. If you leave this blank, you won't get sections for the other tags. --}}
        {{/match}}
        {{/foreach}}

    </div>
    {{/get}}

Another option if you want to control which tags are gotten is to add a filter=tags:[your,list,of,tags] to the first {{#get}}

Oh that works so well thank you Cathy! wrt to the alternative approach would this be the right syntax:

    {{#get "tags" filter="tags:[book,leadership]"}}

1 Like

Yep! That looks good.

1 Like

Slight tweak and it works perfectly :heart_eyes:

{{#get "tags" filter="slug:[book, leadership]"}}
1 Like