I’ve followed your amazing youtube course building a portfolio website, and I would like to add a CSS class to an active filter. I’m an absolute beginner, so I don’t really understand how to do that.
In the youtube comments, you said to ‘in the foreach loop for the filter buttons you can compare $filter with $filterBy and then add a css class or an aria-current attribute if they are the same’
but I can’t seem to make it work. I guess it should go somewhere here, but I’m not sure.
<nav class="filter"> <a href="<?= $page->url() ?>">All</a> <?php foreach ($filters as $filter): ?> <a href="<?= $page->url() ?>?filter=<?= $filter ?>"><?= $filter ?></a> <?php endforeach ?> </nav>
Thank you so much!