I'm having trouble getting what should be a simple relationship between 2 channels to work as expected.
This is how things are set up.
Channel: Apprenticeships - essentially categories, types of apprenticeship (health, construction, catering etc)
Channel: Vacancies - individual apprenticeship courses - each one related to an Apprenticehips entry.
In my template I can show a list of all Vacancy entries with
{% set vacancies = craft.entries.section("vacancies").find() %}
Then loop through them and output field data. This works fine and shows all the vacancy entries.
But I want to be able to filter the entries returned to those that are related to a specific Apprenticeships entry. This filtering is to be based on the third url segment, which is the slug of the Apprenticeship entry.
{% for cat in craft.entries.title(craft.entries.slug(craft.request.segment(3)).limit(1).find()) %}
This works fine and I can output field data from that Apprenticeship entry. Proving, in my mind, that Craft knows which entry I want.
To get only the Vacancy entries that are related to the Apprenticeship entry represented by cat I thought I could simply use 'cat' in another craft.entries tag.
{% set vacancies = craft.entries.section("vacancies").relatedTo(cat) %}
Then loop through vacancies outputting the vacancy field data. But it doesn't return any Vacancy entries even though there definitely some to return.
Where am I going wrong here?