Blog, Website & Page Publishing

GillBraysh
Participant

Print current blog topic on listing page

SOLVE

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 Accepted solution
piersg
Solution
Key Advisor

Print current blog topic on listing page

SOLVE

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

 

View solution in original post

3 Replies 3
piersg
Solution
Key Advisor

Print current blog topic on listing page

SOLVE

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
Member

Print current blog topic on listing page

SOLVE

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
Community Manager

Print current blog topic on listing page

SOLVE

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


¿Sabías que la Comunidad está disponible en Español?
¡Participa hoy en conversaciones en el idioma de tu preferencia,cambiando el idioma en tus configuraciones!

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


0 Upvotes