My entry url structure looks like this:
http://site.com/section/category/subcategory/entry_slug
I'm trying to drill down to specific entries by using the url structure and I'm currently having trouble getting the following to work:
{% set secondSeg = craft.request.getSegment(2) %}
{% set subCategories = craft.categories.group('section').level(2) %}
{% for cat in subCategories.relatedTo(secondSeg).slug(lastSeg) %}
{{category.title}}
{% endfor %}
Currently nothing is returned. If I remove the .relatedTo(secondSeg) parameter in the cat loop, I'm properly getting all of the entries in child category that match the slug. But, the problem is that there is a possibility of certain entries having the same slug under different child categories. I'm not sure if I'm using the relatedTo parameter properly or not.