I am creating a Structure for the main navigation that has two possible choices for the Link: Entries field or a Categories field. The answer I received here showed me how to setup the basics but if the Category page I want to link to is a Sub Category, it will only link to the Parent.
{% set menu = craft.entries.section('navDropDownMenu').all() %}
<ul>
{% nav link in menu %}
<li>
{% if link.entriesURL|length %}
{% if craft.app.request.absoluteUrl == link.entriesFieldURL[0].url %}
<a href="{{ link.entriesFieldURL[0].url }}" class="active">{{ link.title }}</a>
{% else %}
<a href="{{ link.entriesFieldURL[0].url }}">{{ link.title }}</a>
{% endif %}
{% else %}
{% if craft.app.request.absoluteUrl == link.categoryFieldURL[0].url %}
<a href="{{ link.categoryFieldURL[0].url }}" class="active">{{ link.title }}</a>
{% else %}
<a href="{{ link.categoryFieldURL[0].url }}">{{ link.title }}</a>
{% endif %}
{% endif %}
{% ifchildren %}
<ul>
{% children %}
</ul>
{% endifchildren %}
</li>
{% endnav %}
So what I'm trying to figure out is, if I have a category setup like this:
-Shoes
-Tennis
in the context of using the Nav Tag (as above), how do I get the link to 'Tennis' and not 'Shoes'?
I know you can output a nav of Categories, but I wanted to use a Structure if possible because the navigation has a mixture of categories and links to internal pages, and they are mixed together in the navigation as far as sorting goes.