# Exclude Blog Topic

**URL:** <https://community.hubspot.com/t/exclude-blog-topic/69687>\
**Category:** CMS Development\
**Created:** [November 21, 2022, 5:32pm UTC](https://community.hubspot.com/t/exclude-blog-topic/69687 "2022-11-21T17:32:51Z")\
**Posts on this page:** 4\
**Page:** 1

<div class="post-metadata">

**Author:** ![crismartinez](https://d10pqhm3lwygmk.cloudfront.net/user_avatar/community.hubspot.com/crismartinez/32/44503_2.png) [@crismartinez](https://community.hubspot.com/u/crismartinez)\
**Post date:** [November 21, 2022, 5:32pm UTC](https://community.hubspot.com/t/exclude-blog-topic/69687/1 "2022-11-21T17:32:51Z")

</div>

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!

---

<div class="post-metadata">

**Author:** ![BarryGrennan](https://d10pqhm3lwygmk.cloudfront.net/user_avatar/community.hubspot.com/barrygrennan/32/97794_2.png) [@BarryGrennan](https://community.hubspot.com/u/BarryGrennan)\
**Post date:** [November 21, 2022, 7:23pm UTC](https://community.hubspot.com/t/exclude-blog-topic/69687/2 "2022-11-21T19:23:11Z")

</div>

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

```lia-code-sample
{% 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

```lia-code-sample
 {% 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 👍

* * *

 ![profile2022a.jpg](https://d2qpr2jzcazej7.cloudfront.net/original/2X/7/7273a34ccfe3489fceebc8a36eca751481b59531.jpeg)

**Barry Grennan**

[Freelance HubSpot CMS Developer](https://www.seoanseo.ca?utm_source=HubSpotCommunity)

[Website](https://www.seoanseo.ca?utm_source=HubSpotCommunity) | [Contact](https://www.seoanseo.ca/#contact?utm_source=HubSpotCommunity) | [LinkedIn](https://www.linkedin.com/in/barrygrennan)

---

<div class="post-metadata">

**Author:** ![alyssamwilie](https://d10pqhm3lwygmk.cloudfront.net/user_avatar/community.hubspot.com/alyssamwilie/32/2072_2.png) [@alyssamwilie](https://community.hubspot.com/u/alyssamwilie)\
**Post date:** [November 21, 2022, 7:57pm UTC](https://community.hubspot.com/t/exclude-blog-topic/69687/3 "2022-11-21T19:57:56Z")

</div>

@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”.

```lia-code-sample
<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

---

<div class="post-metadata">

**Author:** ![BarryGrennan](https://d10pqhm3lwygmk.cloudfront.net/user_avatar/community.hubspot.com/barrygrennan/32/97794_2.png) [@BarryGrennan](https://community.hubspot.com/u/BarryGrennan)\
**Post date:** [November 21, 2022, 8:07pm UTC](https://community.hubspot.com/t/exclude-blog-topic/69687/4 "2022-11-21T20:07:31Z")

</div>

Ah, nice one.

Bookmarked!

* * *

 ![profile2022a.jpg](https://d2qpr2jzcazej7.cloudfront.net/original/2X/7/7273a34ccfe3489fceebc8a36eca751481b59531.jpeg)

**Barry Grennan**

[Freelance HubSpot CMS Developer](https://www.seoanseo.ca?utm_source=HubSpotCommunity)

[Website](https://www.seoanseo.ca?utm_source=HubSpotCommunity) | [Contact](https://www.seoanseo.ca/#contact?utm_source=HubSpotCommunity) | [LinkedIn](https://www.linkedin.com/in/barrygrennan)
