This may be a simple solution, but for some reason I can’t figure it out. I have two entries that share the same category and I’m trying to get them to display in a nested unordered list (for navigation).
When I use the code below, it lists the two entries separately and repeats the category name twice.
<ul>
<li><a href="http://{site_url}">Home</a></li>
<li><a href="/about-us">About</a></li>
<li><a href="#">Food</a>
<ul>
{exp:channel:entries channel="products" category_group="1" orderby="entry_id" dynamic="no"}
{categories show="17|18|19|20|21"}
<li><a href="#">{category_name}</a>
<ul>
<li><a href="/products/detail/{url_title}">{title}</a></li>
</ul>
</li>
{/categories}
{/exp:channel:entries}
</ul>
</li>The result I get is:
Home
About
Food
-Category 1
—Entry 1
-Category 1
—Entry 2
-Category 2
—Entry 3
-Category 2
—Entry 4
What I want is:
Home
About
Food
-Category 1
—Entry 1
—Entry 2
-Category 2
—Entry 3
—Entry 4