This may be a simple question but I am not sure how to approach it - again trying to work out best practice for these things!
I have a "single" at /our-work
, which among other things displays a projects listing - basically a list of links to the full entry for that project.
I now wish to filter that listing by the category they are in. I also wish to update the URL to reflect that filter e.g. /our-work/branding
.
I have got the below code - listing out all the projects with their links, and also outputting the category links for the filter. When the links are clicked I currently I get an error - unsurprising considering the page doesn't exist.
How can I best achieve both the filtering and the required url change? Any help or pointers gratefully received by a craft beginner!
{% extends "_layouts/main" %}
{% block main %}
{% set categories = craft.categories.group('projectType').level(1).all() %}
{% for category in categories %}
<a href="/our-work/{{ category.slug }}">{{ category.title }}</a>
{% endfor %}
{% for project in craft.entries.section('projects').all() %}
<a href="{{ project.url }}">
{{ project.title }}
</a>
{% endfor %}
{% endblock %}