[wp-trac] [WordPress Trac] #15633: Add class to custom menu item when menu url is found in current page
WordPress Trac
wp-trac at lists.automattic.com
Wed Dec 1 21:06:42 UTC 2010
#15633: Add class to custom menu item when menu url is found in current page
-------------------------+--------------------------------------------------
Reporter: elBradford | Owner:
Type: enhancement | Status: new
Priority: normal | Milestone: Awaiting Review
Component: General | Version: 3.0.2
Severity: normal | Keywords: custom menu
-------------------------+--------------------------------------------------
I found the need to identify custom nav menu items when the page is at a
certain URL. For example,
Menu URL: http://mysite.com/wiki/
Page URL: http://mysite.com/wiki/Moose_Attacks
Anything below http://mysite.com/wiki/ is considered to be "within"
http://mysite.com/wiki/ so I want to add a class to the menu item whenever
that happens.
I made a rough patch with the following code, added just below line 381 of
wp-includes/nav-menu-template.php in wordpress 3.0.2:
{{{
if ( strpos($current_url, untrailingslashit($item_url)) == 0 )
$classes[] = 'current_url_parent';
}}}
This probably brings up other problems, such as other custom menu items
having that class, but I hope this can be considered. Thanks
Bradford
--
Ticket URL: <http://core.trac.wordpress.org/ticket/15633>
WordPress Trac <http://core.trac.wordpress.org/>
WordPress blogging software
More information about the wp-trac
mailing list