[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:17:01 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    
-------------------------+--------------------------------------------------

Comment(by elBradford):

 I had to change my patch a little bit. Replace lines 380-381 with:


 {{{
 if ( untrailingslashit($item_url) == home_url() )
         $classes[] = 'menu-item-home';
 else if ( strpos($current_url, untrailingslashit($item_url)) === 0 )
         $classes[] = 'current-url-parent';
 }}}

 I had to do the else-if because my home page item was being triggered all
 the time.

-- 
Ticket URL: <http://core.trac.wordpress.org/ticket/15633#comment:1>
WordPress Trac <http://core.trac.wordpress.org/>
WordPress blogging software


More information about the wp-trac mailing list