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.
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!
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!
Worked a treat, thanks buddy! Appreciate the help.
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
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