My code is the same as this one:
https://getkirby.com/docs/cookbook/content-structure/filtering-with-tags
Controller of projects.php template:
<?php
return function($page) {
// fetch the basic set of pages
$projects = $page->children()->listed()->flip();
// add the tag filter
if($tag = param('tag')) {
$projects = $projects->filterBy('tags', $tag, ',');
}
// fetch all tags
$tags = $projects->pluck('tags', ',', false);
// apply pagination
$projects = $projects->paginate(9);
$pagination = $projects->pagination();
return compact('projects', 'tags', 'tag', 'pagination');
};
I just added this code in my project.php template:
<?php foreach(str::split($page->tags()) as $tag): ?>
<a href="<?= url('tag:' . urlencode($tag)) ?>"><?= $tag; ?></a>
<?php endforeach ?>
It works great on a version of Kirby 2