Skip to content
● Meet Grav Guard: keep every Grav site you run secure and up to date, all from one place. Free for up to 3 sites. Read more →

Title on results page filtered by taxonomy

Solved by Pedro M View solution

Started by Pedro M 5 years ago · 2 replies · 853 views
5 years ago

Hello there.

Is there a way to display a title with the specified taxonomy filter?

When you click on a taxonomy tag, the articles corresponding to that taxonomy are displayed, but the title of the page is that of the blog.

For example at: http://localhost/grav/blog/tag:tag1, I would like to display in the page title:

N items with tag1 taxonomy found, and not the title of the Blog page.

taxonomy_filter|687x500

Thanks.

4 years ago Solution

Hi
Finally I've found a solution for this question in Grav Coder Theme. Simply I've added this lines to a blog.html.twig:

TWIG
{% if uri.param('category') %}
    {% set page_title = theme_config.listing_title.taxonomy.category | default('Posts in Category: ') ~ uri.param('category') %}
{% elseif uri.param('tag') %}
    {% set page_title = theme_config.listing_title.taxonomy.tag | default('Posts with Tag: ') ~ uri.param('tag') %}
{% else %}
    {% set page_title = theme_config.listing_title.blog | default('Blog') %}
{% endif %}

I hope I helped

Suggested topics

Topic Participants Replies Views Activity
General · by themetman, 23 hours ago
2 40 16 hours ago
General · by Hanns Mattes, 1 week ago
0 121 1 week ago
General · by Karmalakas, 1 week ago
2 185 1 week ago
General · by Hanns Mattes, 3 weeks ago
0 235 3 weeks ago
General · by Dima, 4 weeks ago
1 211 4 weeks ago