Channels: Photographers Photos - entries field handle "photographers" - categories field handle "category"
url structure where segment 2 is the photographer slug and segment 3 is the photo category slug:
domain.com/photographers/john-doe/food
On the photographers detail page I need to pull up the photos entries that are related to that photographer and in the category determined by segment 3
Set at the top of the page and used in a couple of different spots
{# set segment variables so we can use shorthand #}
{% set segment_2 = craft.request.getSegment(2) %}
{% set segment_3 = craft.request.getSegment(3) %}
{# get related photo entries #}
{% set photos = craft.entries.section('photos').relatedTo(entry) %}
Then where I want the photos to display I have the following code which outputs 2 entries from the photos channel. These are both related to the current photographer but in different categories. Only the one entry that is both related to the photographer and the current category should be output.
{# set currentCategory to category id from segment 3 #}
{% set currentCategory = craft.categories.slug(segment_3).first() %}
{% set photos = photos.relatedTo(currentCategory.id) %}
{% for photo in photos %}
{{ photo.title }} <br>
{%endfor %}
I'm not sure how to combine and filter these relations. Please advise.