Skip to content
Grav 2.1 is out: every page speaks Markdown. Read the announcement →

Title on results page filtered by taxonomy

Solved by Pedro M View solution

Started by Pedro M 4 years ago · 2 replies · 728 views
4 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 jeremycherfas, 1 week ago
5 195 2 hours ago
General · by lynbor, 6 days ago
2 129 3 days ago
General · by Old Man Umby, 1 week ago
1 103 1 week ago
General · by Sebastian, 2 weeks ago
1 128 2 weeks ago
General · by Andy Miller, 3 weeks ago
0 251 3 weeks ago