CMS Development

JLanfear
Member

Hiding blog tags

SOLVE

Hi,

 

I have created a module that displays the three most recent posts on my homepage, however, I have also created a Post banner that displays posts with the tag 'featured' on my homepage.

 

Basically in the three latest posts (See below)  I display the tag of the recent post above the title. I am wanting to display the relevant tag but not display the featured tag.

 

JLanfear_0-1617707507225.png

 

Currently, to display the tags above the title I am using 

 

{% for tag in post.tag_list %}
<a class ="latest-post__blog-tags--tags">{{ tag.name }}</a>
{% endfor %}

 

Any help would be appreciated thank you!

0 Upvotes
1 Accepted solution
Kevin-C
Solution
Recognized Expert | Partner
Recognized Expert | Partner

Hiding blog tags

SOLVE

Hey @JLanfear 

 

You can check the value of the tag.name and conditionally print the tag if it's not "featured":

 

{% for tag in post.tag_list %}
  {% if tag.name|lower != 'featured' %}
    <a class ="latest-post__blog-tags--tags">{{ tag.name }}</a>
  {% endif %}
{% endfor %}

 

 

Hope this gets you moving!

View solution in original post

4 Replies 4
racine99
Participant

Hiding blog tags

SOLVE

Hi @Kevin-C 
I did the same, thanks for the tip. But now I have five webpages that need a curated set of three blogs as related blog posts. I would love to have a module where you could choose the blog names to include, but in leu of that, I am using tags and omitting these tags in the blog detail template.

So, how do I compound the tags to omit when listing tags to check for?

I have tried this:
{% if tag.name|lower != 'featured' or tag.name|lower != 'pre-trade' or tag.name|lower != 'data-services' %}

And this:
{% if (tag.name|lower != 'featured') or (tag.name|lower != 'pre-trade') or (tag.name|lower != 'data-services') %}
 
...but neither work on the blog detail template. 

Can you help?
Racine

0 Upvotes
Kevin-C
Solution
Recognized Expert | Partner
Recognized Expert | Partner

Hiding blog tags

SOLVE

Hey @JLanfear 

 

You can check the value of the tag.name and conditionally print the tag if it's not "featured":

 

{% for tag in post.tag_list %}
  {% if tag.name|lower != 'featured' %}
    <a class ="latest-post__blog-tags--tags">{{ tag.name }}</a>
  {% endif %}
{% endfor %}

 

 

Hope this gets you moving!

racine99
Participant

Hiding blog tags

SOLVE

Sorry to possibly re-post, but this is the first time using the community, so not sure you get notified if I don't reply to you. Can you take a look at my question above that build on this issue? Thanks, Racine

0 Upvotes
JLanfear
Member

Hiding blog tags

SOLVE

Worked a treat, thanks buddy! Appreciate the help.