CMS Development

hannalofving
Contributeur | Partenaire solutions Platinum
Contributeur | Partenaire solutions Platinum

How to show all topics in blog listing

Résolue

I only get the topics associated with the 9 blog posts displayed on each page.

As for now, on my first page of my blog I get 5 topics, when I navigate to the second page, viewing my next 9 blog posts, I get 11 topics. 

 

I would like for all my used topics to be showned on all the blog-listing pages. 

How can I do this?

 

This is my code. (The first part is if any topic is selected, here as well I would like for all topics to be shown after the selected topic.)

 

{% if contents_topics %}
      {% if topic %}
           {% set temp = group.public_title ~ " - Exsitec | "%}
           {% set topicName = page_meta.html_title|replace(temp, '') %} 
           <div class="button-group -inline" style="width:100%">
               <a href="{{ group.absolute_url }}" class="tag-item" style="background-color:#c9c9db">
                   {{ topicName }}
               </a>
          </div>
     {% endif %}
     <div class="button-group -inline">
          {% for thisTopic in contents_topics %}
              {% if thisTopic.slug != topic %}
                  <a href="{% if thisTopic.slug == topic %}{{ group.absolute_url }}{% else %}{{ group.absolute_url }}/topic/{{ thisTopic.slug }}{% endif %}" class="tag-item" style="{% if thisTopic.slug == topic %}background-color:#c9c9db {% endif %}"> <!--class="button -filter">-->
                         {{ thisTopic.name }}
                  </a>
                {% endif %}
            {% endfor %}
         </div>
{% endif %}
0 Votes
1 Solution acceptée
tjoyce
Solution
Expert reconnu | Partenaire solutions Elite
Expert reconnu | Partenaire solutions Elite

How to show all topics in blog listing

Résolue

@hannalofving

You can use the "blog topics" HUBL function to accomplish this. Just modify the second part of your code to use the my_topics loop instead of the contents_topics. Keep in mind that topics that do not belong to any blog posts at all, probably will not appear in this list. But, at least your list won't be limited to just the blog posts that are appearing in the page.

{% set my_topics = blog_topics('default', 250) %}
<ul>
{% for item in my_topics %}
<li><a href="{{ blog_tag_url(group.id, item.slug) }}">{{ item }}</a></li>
{% endfor %}
</ul>

If this answer helped, please, mark as solved 😄


tim@belch.io | forms.belch.io | Design your own Beautiful HubSpot Forms; No coding necessary.

Voir la solution dans l'envoi d'origine

4 Réponses
tjoyce
Solution
Expert reconnu | Partenaire solutions Elite
Expert reconnu | Partenaire solutions Elite

How to show all topics in blog listing

Résolue

@hannalofving

You can use the "blog topics" HUBL function to accomplish this. Just modify the second part of your code to use the my_topics loop instead of the contents_topics. Keep in mind that topics that do not belong to any blog posts at all, probably will not appear in this list. But, at least your list won't be limited to just the blog posts that are appearing in the page.

{% set my_topics = blog_topics('default', 250) %}
<ul>
{% for item in my_topics %}
<li><a href="{{ blog_tag_url(group.id, item.slug) }}">{{ item }}</a></li>
{% endfor %}
</ul>

If this answer helped, please, mark as solved 😄


tim@belch.io | forms.belch.io | Design your own Beautiful HubSpot Forms; No coding necessary.

TGerhard
Participant

How to show all topics in blog listing

Résolue

Do you know by any chance why blog_topics("default", 250) returns the list of my tags and not a list of my topics?

There is also only a blog_tag_url function, and no blog_topic_url function. I'm somewhat new to hubspot, so I might confuse something.

0 Votes
hannalofving
Contributeur | Partenaire solutions Platinum
Contributeur | Partenaire solutions Platinum

How to show all topics in blog listing

Résolue

Topics and tags are the same thing. "Topics" was the original name of it, but in 2017 they changed it to Tags.

But you can still find functions for "topics"...

You can read more here (https://www.hubspot.com/product-updates/blog-post-topics-changed-to-tags)

0 Votes
hannalofving
Contributeur | Partenaire solutions Platinum
Contributeur | Partenaire solutions Platinum

How to show all topics in blog listing

Résolue

Thank you!

It works like a charm.