Hey Kirby-Crew! I’m trying to add a class to an active filter. I already tried using this method: Adding classes to active filters but can’t seem to make it work. Here’s my current code.
<?php
$filterBy = get('filter');
$projects = $page
->children()
->listed()
->when($filterBy, function($filterBy) {
return $this->filterBy('category', $filterBy);
})
->paginate(20);
$pagination = $projects->pagination();
?>
<div class="main">
<div class="projects-filter" data-aos="fade-in">
<a href="<?= $page->url() ?>">All</a>
<a href="<?= $page->url() ?>?filter=Residential">Residential</a>
<a href="<?= $page->url() ?>?filter=Commercial">Commercial</a>
<a href="<?= $page->url() ?>?filter=Professional">Professional</a>
</div>
<ul class="projects">
<?php foreach ($projects as $project): ?>
<li data-aos="fade-in">
<a href="<?= $project->url() ?>">
<div class="border-bottom">
<?php if ( $image = $project->images()->sortBy('sort')->first() ) {
echo $image->crop(600,800);
} ?>
</div>
<div class="projects-info">
<div><?= $project->title() ?></div>
<div class="text-right"><?= $project->subtitle() ?></div>
</div>
</a>
</li>
<?php endforeach ?>
</ul>
</div>
Any and all help is highly appreciated! Thanks, W.