Hi Developers,
I tell you my problem
I have a blog with different categories (tag / topics) and on the sidebar of the post template I need to put a different image according to the category to which they belong.
So far no problem, with the “for topic” and the “if”, “elif” and “else” the image I want is shown, the problem comes when a post has more than one assigned category that shows several images and only I want one.
This is the code that I have made:
{% for topic in content.topic_list %}
{% if 'transporte' in topic.slug %}
<a href="link1" rel="noreferrer" target="_blank" >
<img class="hs-cta-img lazy" src="image_cta01.png" alt="{{ topic|title }}"/>
</a>
{% elif 'logistica' in topic.slug %}
<a href="link2" rel="noreferrer" target="_blank" >
<img class="hs-cta-img lazy" src="image_cta02.png" alt="{{ topic|title }}"/>
</a>
{% else %}
<a href="link3" rel="noreferrer" target="_blank" >
<img class="hs-cta-img lazy" src="image_cta03.png" alt="{{ topic|title }}"/>
</a>
{% endif %}
{% endfor %}
Thank you very much for the help!