Skip to content

Instantly share code, notes, and snippets.

@jeremyfelt
Last active December 27, 2015 00:59
Show Gist options
  • Select an option

  • Save jeremyfelt/7241831 to your computer and use it in GitHub Desktop.

Select an option

Save jeremyfelt/7241831 to your computer and use it in GitHub Desktop.
<?php
// $class_names = join( ' ', apply_filters( 'nav_menu_css_class', array_filter( $classes ), $item, $args ) );
add_filter( 'nav_menu_css_class', 'wsuspine_fix_nav_item_classes', 10, 3 );
function wsuspine_fix_nav_item_classes( $classes, $item, $args ) {
if ( in_array( 'current-menu-item', $classes ) )
return array( 'current' );
return array(); //should return an empty array of classes.
// return array( 'my-custom-class' ); // returns a custom array of classes
}
@natejacobson
Copy link
Copy Markdown

So, this is close. It's eliminating all the extra classes but failing to return .current on the current menu item.

@natejacobson
Copy link
Copy Markdown

@natejacobson
Copy link
Copy Markdown

Beautiful! That's it. Can't I give you a brownie point like on stack overflow? Shame.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment