Complex Menu with Child Categories Filter
-
I have a question that I’m aware it’s rather complex, that’s why I haven’t found any similar questions, so… here we go.
Fisrt let me explain the structure I’m dealing with:
All my Content is divided into two Parent Categories: “Art” and “Levels”.
“Art” has child categories, which are names for Works. Like “Duchamp’s Ready-Made” and so on.
Each Work has a bunch of regular posts, organized by its “Levels” which are descriptions of its contents. For instance, “Music” or “History” and so on.
So, if I search for a Work, it will return me all the Posts in this Work category, sorted and organized by its Levels.
Ok, I know, it’s complex. And here’s the deal:
I want that, when viewing a Work Page (category-id.php), the menu shows me ONLY the Child categories of “Levels” that are associated with this particular Work. So, if I have the Level “The Problem” and “Duchamp” has no posts with this Level, I don’t want the menu to show it.
But, what makes it difficult is that each Level is an anchor, so, here’s my code:
function showNiveis() { $listaNiveis = get_categories('child_of=4&orderby=ID&hide_empty=true'); foreach($listaNiveis as $niveis) { echo '<li class="nivelMenu"><a href="#' . $niveis->category_nicename . '" class="execScroll">' . $niveis->cat_name . '</a></li>'; } }
where “childof=4” are the children for the “Levels” category.
Sorry, I know it’s difficult, that’s why I’m banging my head against the wall to solve it.
Thanks in advance!
- The topic ‘Complex Menu with Child Categories Filter’ is closed to new replies.