Hi, trying to exclude the ‘Featured’ tag (in the topics last but I can’t figure out how to with this currently on there
<div class=“blog-tags-wrapper”>
<div class=“blog-tags”>
{% set my_tags = blog_tags( module.select_blog , 5) %}
<a href=“{{ group.absolute_url }}” class=“tag-button active”><span class=“avia_iconbox_title”>Blogs Home</span></a>
{% for item in my_tags %}
<a href=“{{ blog_tag_url(group.id, item.slug) }}” class=“tag-button”><span class=“avia_iconbox_title”>{{ item }}</span></a>
{% endfor %}
</div>
</div>
Thank you!
I imagine if you want to get 5 tags you’ll need to take in 6 in case one of them is featured, so
{% set my_tags = blog_tags( module.select_blog , 6) %}
But that’d leave you in a spot where if would render 6 if Featured isn’t one of them. I don’t think nesting an unless and a loop index requirement in this case will render the desired results, so first you’d want to create a new array and add the tags to it if they’re not featured
{% set tag_array = [] %}
{% for tag in my_tags %}
{% unless tag.slug == "featured" %}
{% do tag_array.append( tag ) %}
{% endunless %}
{% endfor %}
Then go loop through your new array 5 times to eliminate the extra 6th tag if it exists
{% for item in tag_array %}
{% if loop.index <= 5 %}
<a href="{{ blog_tag_url(group.id, item.slug) }}" class="tag-button"><span class="avia_iconbox_title">{{ item }}</span></a>
{% endif %}
{% endfor %}
Shoutout to @alyssamwilie who’s blog I learned about array appends from way back when 
Barry Grennan
Freelance HubSpot CMS Developer
Website | Contact | LinkedIn
@BarryGrennan Haha, might just blow your mind with this rarely used HubL filter --- reject()! No need to loop through the array to find the ones you don’t want, just outright tell the array “I don’t want this one”.
<div class="blog-tags-wrapper">
<div class="blog-tags">
<!-- We'll still update the limit to 6 to make sure we'll always have enough -->
{% set my_tags = blog_tags( module.select_blog , 6) %}
<a href="{{ group.absolute_url }}" class="tag-button active">
<span class="avia_iconbox_title">Blogs Home</span>
</a>
<!-- Use reject to tell the loop we don't want the 'Featured' tag -->
{% for item in my_tags|reject("equalto", "Featured") %}
<!-- Wrap inside of our loop in an unless statement to make sure it doesn't print more than 5 tags -->
{% unless loop.index >= 6 %}
<a href="{{ blog_tag_url(group.id, item.slug) }}" class="tag-button">
<span class="avia_iconbox_title">{{ item }}</span>
</a>
{% endunless %}
{% endfor %}
</div>
</div>
I