CMS Development

hannalofving
投稿者 | Platinum Partner
投稿者 | Platinum Partner

How to show all topics in blog listing

解決

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 いいね!
1件の承認済みベストアンサー
tjoyce
解決策
名誉エキスパート | Elite Partner
名誉エキスパート | Elite Partner

How to show all topics in blog listing

解決

@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.

元の投稿で解決策を見る

4件の返信
tjoyce
解決策
名誉エキスパート | Elite Partner
名誉エキスパート | Elite Partner

How to show all topics in blog listing

解決

@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
参加者

How to show all topics in blog listing

解決

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 いいね!
hannalofving
投稿者 | Platinum Partner
投稿者 | Platinum Partner

How to show all topics in blog listing

解決

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 いいね!
hannalofving
投稿者 | Platinum Partner
投稿者 | Platinum Partner

How to show all topics in blog listing

解決

Thank you!

It works like a charm.