I have a custom walker that extends the Walker class. My code uses the Walker_Page class as it's base as it does pretty much everything else I want but I need to modify it a bit so that it behaves a little differently.
Essentially, I want to prevent the walker from creating new levels of navigation for menu items that are not related to the current page -- that is I only want it to walk deeper levels when the current page is either the current page, or an ancestor of it.
The key to this seems to be the $current_page
(current_object_id) argument that is passed to the start_el
method. If this were also passed to the start_lvl
method, I think this would be easy to code, but start_el
seems to be the only method that gets it.
Any help/direction would be much appreciated.
I would paste my code here, but it's basically the same as Walker_Page