CMS Development

IDArici
Teilnehmer/-in

Alphabetize Blog Tags in Blog Navigation

lösung

Currently, the blog topics in our blog (https://blog.femmepharma.com/menopositivity ) navigation are defaulting to show the most recently updated topic first. I would like them to display alphabetically.

 

I read these two posts and found neither to be helpful.

 

Make a Blog Topic List Appear in Alphabetical Order 

Alphabetize and re-arrange blog category buttons 

 

This is the blog navigation code set up by HubSpot when we moved the blog from WordPress. Any ideas?

 

<div class="title-with-topic-section">
<h1>{{ group.public_title }}</h1>
<a href="javascript&colon;;" class="reveal-blog-nav"><i class="fas fa-bars"></i> Blog Navigation</a>
{% set my_tags = blog_tags(group.id, 250) %}
<ul class="blog-nav" style="display:none;">
<li {% if !topic %}class="active"{% endif %}><a href="{{group.absolute_url}}">All Topics</a></li>
{% for item in my_tags %}
<li {% if topic and topic == item.slug %}class="active"{% endif %}><a href="{{ blog_tag_url(group.id, item.slug) }}">{{ item }}</a></li>
{% endfor %}
</ul>
</div>
{% if not simple_list_page %}

Thanks!

0 Upvotes
1 Akzeptierte Lösung
Stephanie-OG
Lösung
Autorität

Alphabetize Blog Tags in Blog Navigation

lösung

Hi there! 

 

You should be able to use the sort filter on your "my_tags". If you update your code to:

 

<div class="title-with-topic-section">
<h1>{{ group.public_title }}</h1>
<a href="javascript&colon;;" class="reveal-blog-nav"><i class="fas fa-bars"></i> Blog Navigation</a>
{% set my_tags = blog_tags(group.id, 250) %}
<ul class="blog-nav" style="display:none;">
<li {% if !topic %}class="active"{% endif %}><a href="{{group.absolute_url}}">All Topics</a></li>
{% for item in my_tags|sort(False, False, 'name') %}
<li {% if topic and topic == item.slug %}class="active"{% endif %}><a href="{{ blog_tag_url(group.id, item.slug) }}">{{ item }}</a></li>
{% endfor %}
</ul>
</div>
{% if not simple_list_page %}

 

They should appear in alphabetical order. 

 


Stephanie O'Gay Garcia

HubSpot CMS Design & Development

Website | Contact

 

If this helped, please mark it as the solution to your question, thanks!

Lösung in ursprünglichem Beitrag anzeigen

2 Antworten
Stephanie-OG
Lösung
Autorität

Alphabetize Blog Tags in Blog Navigation

lösung

Hi there! 

 

You should be able to use the sort filter on your "my_tags". If you update your code to:

 

<div class="title-with-topic-section">
<h1>{{ group.public_title }}</h1>
<a href="javascript&colon;;" class="reveal-blog-nav"><i class="fas fa-bars"></i> Blog Navigation</a>
{% set my_tags = blog_tags(group.id, 250) %}
<ul class="blog-nav" style="display:none;">
<li {% if !topic %}class="active"{% endif %}><a href="{{group.absolute_url}}">All Topics</a></li>
{% for item in my_tags|sort(False, False, 'name') %}
<li {% if topic and topic == item.slug %}class="active"{% endif %}><a href="{{ blog_tag_url(group.id, item.slug) }}">{{ item }}</a></li>
{% endfor %}
</ul>
</div>
{% if not simple_list_page %}

 

They should appear in alphabetical order. 

 


Stephanie O'Gay Garcia

HubSpot CMS Design & Development

Website | Contact

 

If this helped, please mark it as the solution to your question, thanks!

IDArici
Teilnehmer/-in

Alphabetize Blog Tags in Blog Navigation

lösung

That worked! Thank you so much!

0 Upvotes