Blog, Website & Page Publishing

GillBraysh
Teilnehmer/-in

Print current blog topic on listing page

lösung

We have a blog concise.co.uk/insights. We would like to print out a heading for the listing pages which reflect the topic which has been chosen.  So for example for the url https://www.concise.co.uk/insights/topic/backup-disaster-recovery the heading for that listing page would be the topic name which is Backup & Disaster Recovery.

 

 

0 Upvotes
1 Akzeptierte Lösung
piersg
Lösung
Autorität

Print current blog topic on listing page

lösung

Hi @GillBraysh, and thanks for the tag @sharonlicari.

 

This should do it. Put this in place of whichever title you want to replace, e.g. if you're replacing "Our perspective":

{% if topic %}
{% set my_tags = blog_tags('default', 250) %} {% for item in my_tags %} {% if topic == item.slug %} <h2>{{ item }}</h2> {% endif %} {% endfor %}
{% else %}
<h2>Our perspective</h2>
{% endif %}

 

Edit: there is actually an easier way of doing this.

{% if topic %} 
  {% set topicName = page_meta.html_title|replace(group.html_title ~ ' | ', '') %} 
  <h2>{{ topicName }}</h2>
{% else %}
<h2>Our perspective</h2> {% endif %}

 

Lösung in ursprünglichem Beitrag anzeigen

3 Antworten
piersg
Lösung
Autorität

Print current blog topic on listing page

lösung

Hi @GillBraysh, and thanks for the tag @sharonlicari.

 

This should do it. Put this in place of whichever title you want to replace, e.g. if you're replacing "Our perspective":

{% if topic %}
{% set my_tags = blog_tags('default', 250) %} {% for item in my_tags %} {% if topic == item.slug %} <h2>{{ item }}</h2> {% endif %} {% endfor %}
{% else %}
<h2>Our perspective</h2>
{% endif %}

 

Edit: there is actually an easier way of doing this.

{% if topic %} 
  {% set topicName = page_meta.html_title|replace(group.html_title ~ ' | ', '') %} 
  <h2>{{ topicName }}</h2>
{% else %}
<h2>Our perspective</h2> {% endif %}

 

LoganThompson
Teilnehmer/-in

Print current blog topic on listing page

lösung

I did this and it works good on the first page of the listings, but on any further listing pages it ads the page number. Anyway to remove that?

 

Ie: 

 

Page 1 H1= Business Growth

Page 2 H1= Business Growth (2)

0 Upvotes
sharonlicari
Community-Manager/-in
Community-Manager/-in

Print current blog topic on listing page

lösung

Hey @GillBraysh 

 

Thank you for the information provided. I'll tag a few experts.

 

Hey @Kevin-C @piersg @Chris-M what would you advise in this case?

 

Thanks

Sharon


Did you know that the Community is available in other languages?
Join regional conversations by changing your language settings !




0 Upvotes