Different tags accent colors on one post

Hi,

Let’s say I’m using two tags in a post; both have distinct colors.
Is there a way to display the accent color of each different tags in a single post?

My code works fine for the first tag in the list, however I’m struggling with the second tag.
What am I missing here?

<div class="primary-post-tag" style="--color:{{primary_tag.accent_color}}">
                <a href="{{primary_tag.url}}">{{primary_tag.name}}</a>
</div>
<div class="secondary-post-tag" style="--color:{{accent_color}}">
                {{tags from="2"}}
</div>

Thanks for your help.

Try using foreach to access the tag context:

    {{#foreach tags from="2" limit="1" }}
        <div class="secondary-post-tag" style="--color:{{accent_color}}">
            <a href="{{url absolute="true"}}">{{name}}</a>
        </div>
    {{/foreach}}

Remove the limit if you want to show more than one secondary tag

3 Likes

That worked perfectly, thank you @Spiritix !

2 Likes