Posted By

wpCanyon on 12/17/10


Tagged

wordpress


Versions (?)

Adding Classes to the Current Page Item in wp_nav_menu()


 / Published in: PHP
 

URL: http://wpcanyon.com/tipsandtricks/adding-classes-to-the-current-page-item-in-wp_nav_menu/

  1. add_filter( 'nav_menu_css_class', 'additional_active_item_classes', 10, 2 );
  2.  
  3. function additional_active_item_classes($classes = array(), $menu_item = false){
  4.  
  5. if(in_array('current-menu-item', $menu_item->classes)){
  6. $classes[] = 'active';
  7. }
  8.  
  9. return $classes;
  10. }

Report this snippet  

You need to login to post a comment.