Blog, Website & Page Publishing

GillBraysh
Participante

Print current blog topic on listing page

resolver

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 Avaliação positiva
1 Solução aceita
piersg
Solução
Conselheiro(a) de destaque

Print current blog topic on listing page

resolver

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 %}

 

Exibir solução no post original

3 Respostas 3
piersg
Solução
Conselheiro(a) de destaque

Print current blog topic on listing page

resolver

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
Participante

Print current blog topic on listing page

resolver

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 Avaliação positiva
sharonlicari
Gerente da Comunidade
Gerente da Comunidade

Print current blog topic on listing page

resolver

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 Avaliação positiva