Exclude all blog posts with a specific tag from blog listing page

SOLVE
Occasional Contributor

Hello, 

 

Is there a way to exclude all posts with a specific tag from my blog listing page but show all others?

 

Thank you

Reply
0 Upvotes
1 Accepted solution

Accepted Solutions
Occasional Contributor

Figured it out:

 

{% unless 'topic goes here' in content.topic_list|map('name') %}

content markup goes here

{% endunless %}

Reply
0 Upvotes
5 Replies 5
Occasional Contributor

Figured it out:

 

{% unless 'topic goes here' in content.topic_list|map('name') %}

content markup goes here

{% endunless %}

Reply
0 Upvotes
Highlighted
Occasional Contributor

Can you elaborate on how you got this to work?  I am very new to hubl.

{% unless 'Tip' in content.topic_list|map('name') %}
                   {% for content in topic_posts %}
markup
{% endunless %}

I know this isn't right.... can you use this with {% content in contents %}  ?

 

Reply
0 Upvotes
Occasional Contributor

So this is how I made use of it. You should be able to switch out 'topic_list' for the variables listed here under blog variables: https://designers.hubspot.com/docs/hubl/hubl-supported-variables. 

 

{% for topic in content.topic_list %}
{% unless 'Topic to Exclude Here' in content.topic_list|map('name') %}
        {% if loop.first %}
            {% set related_posts = blog_recent_topic_posts('default', 5 ) %}
            {% for post in related_posts %}
                {% unless content.absolute_url == post.absolute_url %}
                    <div class="topic post container class">
                        <div class=" some title class"><a href="{{post.absolute_url}}">{{ post.name}}</a></div>
                        <div class="some post image class"><img src="{{ post.featured_image }}" alt="{{ post.name }}"></div>
                    </div>
                {% endunless %}

            {% endfor %}
        {% endif %}
{% endunless %}
Reply
0 Upvotes
Occasional Contributor

I can't get that code to produce any results.  It also says I have a missing {% endfor %}.

 

This is how I tried it, was 'name' supposed to be replaced?

{% for topic in content.topic_list %}
{% unless 'Tip' in content.topic_list|map('name') %}
        {% if loop.first %}
            {% set related_posts = blog_recent_topic_posts('default', 5 ) %}
            {% for post in related_posts %}
                {% unless content.absolute_url == post.absolute_url %}
                    <div class="topic post container class">
                        <div class=" some title class"><a href="{{post.absolute_url}}">{{ post.name}}</a></div>
                        <div class="some post image class"><img src="{{ post.featured_image }}" alt="{{ post.name }}"></div>
                    </div>
                {% endunless %}

            {% endfor %}
        {% endif %}
{% endunless %}
                  {% endfor %}
Reply
0 Upvotes
Occasional Contributor

The code looks right did you place the module into the blog template?

{% for topic in content.topic_list %}
{% unless 'Tip' in content.topic_list|map('name') %}
        {% if loop.first %}
            {% set related_posts = blog_recent_topic_posts('default', 5 ) %}
            {% for post in related_posts %}
                {% unless content.absolute_url == post.absolute_url %}
                    <div class="topic post container class">
                        <div class=" some title class"><a href="{{post.absolute_url}}">{{ post.name}}</a></div>
                        <div class="some post image class"><img src="{{ post.featured_image }}" alt="{{ post.name }}"></div>
                    </div>
                {% endunless %}
            {% endfor %}
        {% endif %}
{% endunless %}
{% endfor %} 

 It doesn't show anything until the module is placed into the blog template.

Reply
0 Upvotes