php - Displaying sub-categories in sidebar when parent category selected -


what i'm trying achieve in wp 3.1.x using wp_nav_menu function, have menu such as:

-- category 1 -- category 2 -- category 3 -- category 4 -- category 5 -- category 6 

but when you're on 'category 2' displays as:

-- category 1 -- category 2   -- sub category 1   -- sub category 2   -- sub category 3 -- category 3 -- category 4 -- category 5 -- category 6 

ps. i'm not looking css hide/show functionality, can achieved easily.

pps. possible solution extending walker_nav_menu class?

if subclass walker_nav_menu class can override display_element function , conditionally remove item's children before looped through.

if (!$element->current && !$element->current_item_ancestor && isset( $children_elements[$id])) {    unset( $children_elements[ $id ] ); } 

this remove children of item not current, need check item's type if want categories. complete walker this: https://gist.github.com/954627


Comments

Popular posts from this blog

objective c - Change font of selected text in UITextView -

php - Accessing POST data in Facebook cavas app -

c# - Getting control value when switching a view as part of a multiview -