[wp-hackers] How do I get my wp_nav_menu single category post to highlight the entire ancestor trail?
Dan Smart
dan at dansmart.co.uk
Wed Sep 8 09:32:53 UTC 2010
Hi everyone,
I posted this on http://wordpress.stackexchange.com but was told it wasn't
possible to do what I'm attemptin to do, so I thought I'd bring it here. At
least, it should be something that is fixed in 3.1.
http://wordpress.stackexchange.com/questions/1481/how-do-i-get-my-wp-nav-men
u-single-category-page-to-highlight-the-parent
With the new wp_nav_menu system, it is possible to add a category as a menu
item, so in my example I have a 'news' category, which is a submenu item of
'About'.
About (page)
--news (category)
--history (page)
--contact us (page)
The menu highlighting CSS picks up from current-menu-parent and
current-menu-ancestor, so that when I'm in a submenu section, the top level
menu item (e.g. 'About') is highlighted when I visit 'news'.
This works fine, apart from when I visit a post in the 'news' category,
which matches is_single() and in_category('news').
As far as I can see in Firebug, the 'current-menu-parent' and
'current-menu-ancestor' is applied to the 'news' menu item, however it's not
applied to the 'About' top level menu item.
It seems that the initial menu ancestors are not being set up properly in
_wp_menu_item_classes_by_context() in wp-includes/nav-menu-template.php?
I really don't want to have to go down the maintenance challenge of a patch
in core.
Any ideas?
Thanks, Dan
----------------------------------------------------------------------------
---------
Dan Smart - Freelance Web Developer
Web: www.dansmart.co.uk
Tel: +447931588361
Follow me at: www.twitter.com/danielsmart
More information about the wp-hackers
mailing list