Hi guys and gals, here's one for the brightest of you:
I've built a huge dynamic child page lister.
I have 3 levels, here's an example:
- Parent
- child
- sub child
- sub child
- child
- child
- sub child
- sub child
- child
Here’s how it needs to work:
When on the parent, show this:
- Parent (current)
- child
- child
- child
When clicked into the child which has subs, needs show this:
- Parent
- child (current)
- sub child
- sub child
- child
- child
- child (current)
(the same would be shown, if the user proceeds into the sub child)
Here's when I run into trouble: I'm using wp_list_pages
to generate the lists and depth to show subs when I need to, problem is, it gives me all subs in the stack, even though, I only need the subs of the current page (or of the current pages' ancestor, which would be a first-child in the tree) to be shown and the other subs hidden, while showing all children.
So instead of showing the list above, it gives me the full list:
- Parent
- child (current)
- sub child
- sub child
- child
- child
- sub child
- sub child
- child (current)
Now I can easily get the list of current siblings, can get the children of current, it's place in the tree, no problem, I can even solve this by separating the wp_list_pages
output and bringing the current to the top, it's subs right under it and the other non-open pages below it, but this is not the objective.
So, is there anyone that can figure this one out?
On a side note: Here's a not-very-kosher jQuery workaround I made (removing the unnecessary elements with javascript), the issue still remains, can we make wordpress do this without javascript hacks?
$("#side_nav li").not(".current_page_item").not(".current_page_ancestor").not(".current_page_parent").has("ul.children").children("ul.children").remove();