Adding Classes to the Current Page Item in wp_nav_menu()


/ Published in: PHP
Save to your folder(s)



Copy this code and paste it in your HTML
  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. }

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

Report this snippet


Comments

RSS Icon Subscribe to comments

You need to login to post a comment.