CMS Development

MaximSiebert
Member | Partner
Member | Partner

Printing tag title on tag page

SOLVE

I'd like to print the tag title at the top of the blog index page when a user visits '/tag/announcements' for example. 

 

I can't seem to find how to do this anywhere. Ideally this would be wrapped in an if statement that only shows the title when the user is on a tag page.

0 Upvotes
1 Accepted solution
AJLaPorte_diagr
Solution
Key Advisor

Printing tag title on tag page

SOLVE

Hi @MaximSiebert ,

 

Inside of your blog loop code you'd want to do something similar to:

 

{% if topic %}
  <h2>All {{ topic | capitalize }} Posts</h2>
{% endif %}

This would be telling it that if it's a topic page, add this H2 into the area. For example, this chunk of code would create a header on the page and depending on what it is (topic page, author page, normal listing page) it would put the header accordingly:

 

{% if blog_author %}
    <h2>Posts by {{ blog_author.display_name }}</h2>
{% elif topic %}
    <h2>All {{ topic | capitalize }} Posts</h2>
{% else %}
    <h2>Latest Posts</h2>
{% endif %}

Hopefully, this helps point you in the right direction.

 

-AJ

 

-----------------------
AJ LaPorte
www.wsol.com

View solution in original post

2 Replies 2
AJLaPorte_diagr
Solution
Key Advisor

Printing tag title on tag page

SOLVE

Hi @MaximSiebert ,

 

Inside of your blog loop code you'd want to do something similar to:

 

{% if topic %}
  <h2>All {{ topic | capitalize }} Posts</h2>
{% endif %}

This would be telling it that if it's a topic page, add this H2 into the area. For example, this chunk of code would create a header on the page and depending on what it is (topic page, author page, normal listing page) it would put the header accordingly:

 

{% if blog_author %}
    <h2>Posts by {{ blog_author.display_name }}</h2>
{% elif topic %}
    <h2>All {{ topic | capitalize }} Posts</h2>
{% else %}
    <h2>Latest Posts</h2>
{% endif %}

Hopefully, this helps point you in the right direction.

 

-AJ

 

-----------------------
AJ LaPorte
www.wsol.com

MaximSiebert
Member | Partner
Member | Partner

Printing tag title on tag page

SOLVE

Perfect! thank you @AJLaPorte_diagr 

0 Upvotes