CMS Development

jwill377
Membro

Display only 1 tag on blog index card instead of multiple

resolver

How would I go about having only 1 tag listed on each blog post card on the index page instead of having multiple tags displaying?

0 Avaliação positiva
1 Solução aceita
Teun
Solução
Especialista reconhecido(a) | Parceiro Diamante
Especialista reconhecido(a) | Parceiro Diamante

Display only 1 tag on blog index card instead of multiple

resolver

Two solutions to handle this:

<div class="category">
  {% for topic in content.topic_list %}
    {% if loop.first %}
      <a href="{{ topic.slug }}" class="topic-link">{{ topic.name }}</a>
    {% endif %}
  {% endfor %}
</div>

Second option:

<div class="category">
  {% set firstTopic = content.topic_list[0] %}
  {% if firstTopic %}
    <a href="{{ firstTopic.slug }}" class="topic-link">{{ firstTopic.name }}</a>
  {% endif %}
</div>


Learn more about HubSpot by following me on LinkedIn or YouTube

Did my answer solve your issue? Help the community by marking it as the solution.


Exibir solução no post original

4 Respostas 4
Teun
Especialista reconhecido(a) | Parceiro Diamante
Especialista reconhecido(a) | Parceiro Diamante

Display only 1 tag on blog index card instead of multiple

resolver

Hi @jwill377 ,

 

Could you share a bit of your current code so we can tweak it?
You could do something like this:

{% set firstTopic = content.topic_list[0] %}

{{firstTopic.name}} // Will show the name of the first topic only.

 



Learn more about HubSpot by following me on LinkedIn or YouTube

Did my answer solve your issue? Help the community by marking it as the solution.


0 Avaliação positiva
jwill377
Membro

Display only 1 tag on blog index card instead of multiple

resolver

My current code is:


<div class="category">
{% for topic in content.topic_list %}
<a href="{{ topic.slug }}" class="topic-link">{{ topic.name }}</a>
{% endfor %}
</div>

0 Avaliação positiva
Teun
Solução
Especialista reconhecido(a) | Parceiro Diamante
Especialista reconhecido(a) | Parceiro Diamante

Display only 1 tag on blog index card instead of multiple

resolver

Two solutions to handle this:

<div class="category">
  {% for topic in content.topic_list %}
    {% if loop.first %}
      <a href="{{ topic.slug }}" class="topic-link">{{ topic.name }}</a>
    {% endif %}
  {% endfor %}
</div>

Second option:

<div class="category">
  {% set firstTopic = content.topic_list[0] %}
  {% if firstTopic %}
    <a href="{{ firstTopic.slug }}" class="topic-link">{{ firstTopic.name }}</a>
  {% endif %}
</div>


Learn more about HubSpot by following me on LinkedIn or YouTube

Did my answer solve your issue? Help the community by marking it as the solution.


jwill377
Membro

Display only 1 tag on blog index card instead of multiple

resolver

The second option works great! Thank you so much!!